From 4507cf9f8756108d88925b88d70f2a7c9035a89a Mon Sep 17 00:00:00 2001 From: Robinson Date: Fri, 30 Apr 2021 18:21:01 +0200 Subject: [PATCH] Removed RemoteObject.close() --- src/dorkbox/network/rmi/RemoteObject.kt | 5 ----- src/dorkbox/network/rmi/RmiClient.kt | 15 ++------------- src/dorkbox/network/rmi/RmiManagerConnections.kt | 6 ++++++ 3 files changed, 8 insertions(+), 18 deletions(-) diff --git a/src/dorkbox/network/rmi/RemoteObject.kt b/src/dorkbox/network/rmi/RemoteObject.kt index 1dcc5cb1..d054e33e 100644 --- a/src/dorkbox/network/rmi/RemoteObject.kt +++ b/src/dorkbox/network/rmi/RemoteObject.kt @@ -81,9 +81,4 @@ interface RemoteObject { * instead of invoking the remote `equals()` method on the object. */ fun enableEquals(enabled: Boolean) - - /** - * Causes this RemoteObject to stop listening to the connection for method invocation response messages. - */ - fun close() } diff --git a/src/dorkbox/network/rmi/RmiClient.kt b/src/dorkbox/network/rmi/RmiClient.kt index eff41b8f..d90be2d3 100644 --- a/src/dorkbox/network/rmi/RmiClient.kt +++ b/src/dorkbox/network/rmi/RmiClient.kt @@ -22,11 +22,7 @@ import kotlinx.coroutines.runBlocking import java.lang.reflect.InvocationHandler import java.lang.reflect.Method import java.util.* -import kotlin.coroutines.Continuation -import kotlin.coroutines.CoroutineContext -import kotlin.coroutines.EmptyCoroutineContext -import kotlin.coroutines.resume -import kotlin.coroutines.resumeWithException +import kotlin.coroutines.* object MyUnconfined : CoroutineDispatcher() { override fun isDispatchNeeded(context: CoroutineContext): Boolean = false @@ -56,7 +52,6 @@ internal class RmiClient(val isGlobal: Boolean, companion object { private val methods = RmiUtils.getMethods(RemoteObject::class.java) - private val closeMethod = methods.find { it.name == "close" } private val toStringMethod = methods.find { it.name == "toString" } private val hashCodeMethod = methods.find { it.name == "hashCode" } private val equalsMethod = methods.find { it.name == "equals" } @@ -75,7 +70,7 @@ internal class RmiClient(val isGlobal: Boolean, private val EMPTY_ARRAY: Array = Collections.EMPTY_LIST.toTypedArray() as Array } - private var timeoutMillis: Long = 3000 + private var timeoutMillis: Long = 3_000L private var isAsync = false private var enableToString = false @@ -152,11 +147,6 @@ internal class RmiClient(val isGlobal: Boolean, if (method.declaringClass == RemoteObject::class.java) { // manage all of the RemoteObject proxy methods when (method) { - closeMethod -> { - connection.rmiConnectionSupport.removeProxyObject(rmiObjectId) - return null - } - setResponseTimeoutMethod -> { timeoutMillis = (args!![0] as Int).toLong() require(timeoutMillis >= 0) { "ResponseTimeout must be >= 0"} @@ -209,7 +199,6 @@ internal class RmiClient(val isGlobal: Boolean, } // setup the RMI request - val invokeMethod = MethodRequest() // if this is a kotlin suspend function, the continuation arg will NOT be here (it's replaced at runtime)! diff --git a/src/dorkbox/network/rmi/RmiManagerConnections.kt b/src/dorkbox/network/rmi/RmiManagerConnections.kt index 10677792..2c4b2297 100644 --- a/src/dorkbox/network/rmi/RmiManagerConnections.kt +++ b/src/dorkbox/network/rmi/RmiManagerConnections.kt @@ -70,6 +70,12 @@ internal class RmiManagerConnections(logger: KLogger, return proxyObject as Iface } + /** + * on the "client" to remove a connection-specific remote object (that exists on the server) + */ + fun deleteRemoteObject(connection: Connection, rmiId: Int) { + removeProxyObject(rmiId) + } /** * on the "client" to create a connection-specific remote object (that exists on the server)