add command for shut down all threads
This commit is contained in:
@@ -15,7 +15,8 @@ class DebugClInterface {
|
|||||||
"refloc - refresh all car locations\n" +
|
"refloc - refresh all car locations\n" +
|
||||||
"sonar [car_id] - get sonar data\n" +
|
"sonar [car_id] - get sonar data\n" +
|
||||||
"dbinfo [car_id] [type] - refresh all car locations\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() {
|
fun run() {
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import car.Dropper
|
import car.Dropper
|
||||||
|
import car.client.Client
|
||||||
|
|
||||||
val carServerPort: Int = 7925
|
val carServerPort: Int = 7925
|
||||||
val webServerPort: Int = 7926
|
val webServerPort: Int = 7926
|
||||||
@@ -23,4 +24,5 @@ fun main(args: Array<String>) {
|
|||||||
carsDestroy.interrupt()
|
carsDestroy.interrupt()
|
||||||
carServer.interrupt()
|
carServer.interrupt()
|
||||||
webServer.interrupt()
|
webServer.interrupt()
|
||||||
|
Client.shutDownClient()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,17 +10,22 @@ import java.net.ConnectException
|
|||||||
|
|
||||||
object Client {
|
object Client {
|
||||||
|
|
||||||
|
val group: NioEventLoopGroup = NioEventLoopGroup()
|
||||||
val bootstrap: Bootstrap = makeBootstrap()
|
val bootstrap: Bootstrap = makeBootstrap()
|
||||||
|
|
||||||
private fun makeBootstrap(): Bootstrap {
|
private fun makeBootstrap(): Bootstrap {
|
||||||
val group = NioEventLoopGroup()
|
|
||||||
val b = Bootstrap()
|
val b = Bootstrap()
|
||||||
b.group(group).channel(NioSocketChannel().javaClass).handler(ClientInitializer())
|
b.group(group).channel(NioSocketChannel().javaClass).handler(ClientInitializer())
|
||||||
.attr(AttributeKey.newInstance<String>("url"), "")
|
.attr(AttributeKey.newInstance<String>("url"), "")
|
||||||
.attr(AttributeKey.newInstance<Int>("uid"), 0)
|
.attr(AttributeKey.newInstance<Int>("uid"), 0)
|
||||||
|
.attr(AttributeKey.newInstance<IntArray>("angles"), IntArray(0))
|
||||||
return b
|
return b
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun shutDownClient() {
|
||||||
|
group.shutdownGracefully()
|
||||||
|
}
|
||||||
|
|
||||||
fun <T> sendRequest(request: HttpRequest, host: String, port: Int, options: Map<String, T>) {
|
fun <T> sendRequest(request: HttpRequest, host: String, port: Int, options: Map<String, T>) {
|
||||||
try {
|
try {
|
||||||
bootstrap.attr(AttributeKey.valueOf<String>("url"), request.uri())
|
bootstrap.attr(AttributeKey.valueOf<String>("url"), request.uri())
|
||||||
|
|||||||
Reference in New Issue
Block a user