From 23ef5e499b681be5035ef3a7e35daa9d87469be2 Mon Sep 17 00:00:00 2001 From: nathan Date: Thu, 3 Sep 2020 14:36:24 +0200 Subject: [PATCH] Fixed polling --- src/dorkbox/network/Client.kt | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/dorkbox/network/Client.kt b/src/dorkbox/network/Client.kt index 6776f590..5b504593 100644 --- a/src/dorkbox/network/Client.kt +++ b/src/dorkbox/network/Client.kt @@ -352,14 +352,15 @@ open class Client(config: Configuration = Configuration if (canFinishConnecting) { isConnected = true - // we poll for new messages AFTER `handshake.handshakeDone`, because the aeron media driver will queue up the messages for us. - // we want to make sure to call notify connect BEFORE processing new messages. - // have to make a new thread to listen for incoming data! // SUBSCRIPTIONS ARE NOT THREAD SAFE! Only one thread at a time can poll them actionDispatch.launch { listenerManager.notifyConnect(newConnection) + } + // these have to be in two SEPARATE actionDispatch.launch commands.... otherwise... + // if something inside of notifyConnect is blocking or suspends, then polling will never happen! + actionDispatch.launch { val pollIdleStrategy = config.pollIdleStrategy while (!isShutdown()) {