diff --git a/src/dorkbox/network/rmi/RemoteObjectStorage.kt b/src/dorkbox/network/rmi/RemoteObjectStorage.kt index 521f3fcf..3ae39ddb 100644 --- a/src/dorkbox/network/rmi/RemoteObjectStorage.kt +++ b/src/dorkbox/network/rmi/RemoteObjectStorage.kt @@ -63,6 +63,7 @@ class RemoteObjectStorage(val logger: KLogger) { companion object { const val INVALID_RMI = 0 + const val ASYNC_RMI = 1 } // this is the ID -> Object RMI map. The RMI ID is used (not the kryo ID) diff --git a/src/dorkbox/network/rmi/RmiMessageManager.kt b/src/dorkbox/network/rmi/RmiMessageManager.kt index 390543b9..1df2f22f 100644 --- a/src/dorkbox/network/rmi/RmiMessageManager.kt +++ b/src/dorkbox/network/rmi/RmiMessageManager.kt @@ -311,7 +311,7 @@ internal class RmiMessageManager(logger: KLogger, val rmiId = RmiUtils.unpackUnsignedRight(message.packedId) val cachedMethod = message.cachedMethod val args = message.args - val sendResponse = rmiId != 1 // async is always with a '1', and we should NOT send a message back if it is '1' + val sendResponse = rmiId != RemoteObjectStorage.ASYNC_RMI // async is always with a '1', and we should NOT send a message back if it is '1' logger.trace { "RMI received: $rmiId" } diff --git a/src/dorkbox/network/rmi/RmiResponseManager.kt b/src/dorkbox/network/rmi/RmiResponseManager.kt index 57085c87..3ebc610f 100644 --- a/src/dorkbox/network/rmi/RmiResponseManager.kt +++ b/src/dorkbox/network/rmi/RmiResponseManager.kt @@ -33,15 +33,17 @@ import kotlin.concurrent.write internal class RmiResponseManager(private val logger: KLogger, private val actionDispatch: CoroutineScope) { companion object { val TIMEOUT_EXCEPTION = Exception() - val ASYNC_WAITER = RmiWaiter(1) // this is never waited on, we just need this to optimize how we assigned waiters. + val ASYNC_WAITER = RmiWaiter(RemoteObjectStorage.ASYNC_RMI) // this is never waited on, we just need this to optimize how we assigned waiters. } // Response ID's are for ALL in-flight RMI on the network stack. instead of limited to (originally) 64, we are now limited to 65,535 // these are just looped around in a ring buffer. // These are stored here as int, however these are REALLY shorts and are int-packed when transferring data on the wire - // 64,000 IN FLIGHT RMI method invocations is plenty - private val maxValuesInCache = 65535 - 2 // -2 because '0' and '1' are reserved + // 65535 IN FLIGHT RMI method invocations is plenty + // 0 is reserved for INVALID + // 1 is reserved for ASYNC + private val maxValuesInCache = 65535 private val rmiWaiterCache = Channel(maxValuesInCache) private val pendingLock = ReentrantReadWriteLock()