2021-04-29 10:25:25 +02:00
|
|
|
package dorkboxTest.network
|
|
|
|
|
|
|
|
import org.junit.Test
|
|
|
|
|
|
|
|
class PingTest : BaseTest() {
|
|
|
|
@Test
|
|
|
|
fun onServerPing() {
|
2021-04-30 18:22:38 +02:00
|
|
|
// val serverSuccess = atomic(false)
|
|
|
|
// val clientSuccess = atomic(false)
|
|
|
|
//
|
|
|
|
// run {
|
|
|
|
// val configuration = serverConfig()
|
|
|
|
//
|
|
|
|
// val server: Server<Connection> = Server(configuration)
|
|
|
|
// addEndPoint(server)
|
|
|
|
// server.bind()
|
|
|
|
//
|
|
|
|
// server.onPing { ping ->
|
|
|
|
// serverSuccess.value = true
|
|
|
|
// println("Ping info ${ping.time}")
|
|
|
|
// close()
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
// run {
|
|
|
|
// val config = clientConfig()
|
|
|
|
//
|
|
|
|
// val client: Client<Connection> = Client(config)
|
|
|
|
// addEndPoint(client)
|
|
|
|
//
|
|
|
|
// client.onConnect {
|
|
|
|
// clientSuccess.value = true
|
|
|
|
//
|
|
|
|
// it.ping {
|
|
|
|
// println("received ping back! Val: $time")
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
// client.onDisconnect {
|
|
|
|
// stopEndPoints()
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
// runBlocking {
|
|
|
|
// try {
|
|
|
|
// client.connect(LOOPBACK)
|
|
|
|
// } catch (e: Exception) {
|
|
|
|
// stopEndPoints()
|
|
|
|
// throw e
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
//
|
|
|
|
// waitForThreads()
|
|
|
|
//
|
|
|
|
// Assert.assertTrue(serverSuccess.value)
|
|
|
|
// Assert.assertTrue(clientSuccess.value)
|
2021-04-29 10:25:25 +02:00
|
|
|
}
|
|
|
|
}
|