add command for shut down all threads

This commit is contained in:
MaximZaitsev
2016-08-23 13:38:20 +03:00
parent 25d4c70d3f
commit c04f1d207e
3 changed files with 10 additions and 2 deletions
+2 -1
View File
@@ -15,7 +15,8 @@ class DebugClInterface {
"refloc - refresh all car locations\n" +
"sonar [car_id] - get sonar data\n" +
"dbinfo [car_id] [type] - refresh all car locations\n." +
"type is string name of value or int value. available values: MEMORYSTATS - 0"
"type is string name of value or int value. available values: MEMORYSTATS - 0\n" +
"stop - exit from this interface and stop all threads\n"
fun run() {
+2
View File
@@ -1,4 +1,5 @@
import car.Dropper
import car.client.Client
val carServerPort: Int = 7925
val webServerPort: Int = 7926
@@ -23,4 +24,5 @@ fun main(args: Array<String>) {
carsDestroy.interrupt()
carServer.interrupt()
webServer.interrupt()
Client.shutDownClient()
}
+6 -1
View File
@@ -10,17 +10,22 @@ import java.net.ConnectException
object Client {
val group: NioEventLoopGroup = NioEventLoopGroup()
val bootstrap: Bootstrap = makeBootstrap()
private fun makeBootstrap(): Bootstrap {
val group = NioEventLoopGroup()
val b = Bootstrap()
b.group(group).channel(NioSocketChannel().javaClass).handler(ClientInitializer())
.attr(AttributeKey.newInstance<String>("url"), "")
.attr(AttributeKey.newInstance<Int>("uid"), 0)
.attr(AttributeKey.newInstance<IntArray>("angles"), IntArray(0))
return b
}
fun shutDownClient() {
group.shutdownGracefully()
}
fun <T> sendRequest(request: HttpRequest, host: String, port: Int, options: Map<String, T>) {
try {
bootstrap.attr(AttributeKey.valueOf<String>("url"), request.uri())