From e7a7ec973714096a0a6d4405a1b33ea4da721401 Mon Sep 17 00:00:00 2001 From: nathan Date: Thu, 27 Aug 2020 00:45:09 +0200 Subject: [PATCH] Code polish --- src/dorkbox/network/rmi/RmiManagerConnections.kt | 8 ++++---- src/dorkbox/network/rmi/RmiManagerGlobal.kt | 4 ++-- .../serialization/ClassRegistrationIfaceAndImpl.kt | 3 ++- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/dorkbox/network/rmi/RmiManagerConnections.kt b/src/dorkbox/network/rmi/RmiManagerConnections.kt index 9134ec35..257d64bb 100644 --- a/src/dorkbox/network/rmi/RmiManagerConnections.kt +++ b/src/dorkbox/network/rmi/RmiManagerConnections.kt @@ -71,11 +71,11 @@ internal class RmiManagerConnections(logger: KLogger, /** * on the "client" to create a connection-specific remote object (that exists on the server) */ - suspend fun createRemoteObject(connection: Connection, interfaceClassId: Int, objectParameters: Array?, callback: suspend (Int, Iface) -> Unit) { + suspend fun createRemoteObject(connection: Connection, kryoId: Int, objectParameters: Array?, callback: suspend (Int, Iface) -> Unit) { val callbackId = rmiGlobalSupport.registerCallback(callback) // There is no rmiID yet, because we haven't created it! - val message = ConnectionObjectCreateRequest(RmiUtils.packShorts(interfaceClassId, callbackId), objectParameters) + val message = ConnectionObjectCreateRequest(RmiUtils.packShorts(kryoId, callbackId), objectParameters) // We use a callback to notify us when the object is ready. We can't "create this on the fly" because we // have to wait for the object to be created + ID to be assigned on the remote system BEFORE we can create the proxy instance here. @@ -89,12 +89,12 @@ internal class RmiManagerConnections(logger: KLogger, */ suspend fun onConnectionObjectCreateRequest(endPoint: EndPoint, connection: CONNECTION, message: ConnectionObjectCreateRequest) { - val interfaceClassId = RmiUtils.unpackLeft(message.packedIds) + val kryoId = RmiUtils.unpackLeft(message.packedIds) val callbackId = RmiUtils.unpackRight(message.packedIds) val objectParameters = message.objectParameters // We have to lookup the iface, since the proxy object requires it - val implObject = endPoint.serialization.createRmiObject(interfaceClassId, objectParameters) + val implObject = endPoint.serialization.createRmiObject(kryoId, objectParameters) val response = if (implObject is Exception) { // whoops! diff --git a/src/dorkbox/network/rmi/RmiManagerGlobal.kt b/src/dorkbox/network/rmi/RmiManagerGlobal.kt index d9ecfb00..4b7734e2 100644 --- a/src/dorkbox/network/rmi/RmiManagerGlobal.kt +++ b/src/dorkbox/network/rmi/RmiManagerGlobal.kt @@ -62,8 +62,8 @@ internal class RmiManagerGlobal(logger: KLogger, // duplicates are fine, as they represent the same object (as specified by the ID) on the remote side. - val classId = serialization.getClassId(interfaceClass) - val cachedMethods = serialization.getMethods(classId) + val kryoClassId = serialization.getKryoIdForRmi(interfaceClass) + val cachedMethods = serialization.getMethods(kryoClassId) val name = "<${connection.endPoint().type.simpleName}-proxy #$rmiId>" diff --git a/src/dorkbox/network/serialization/ClassRegistrationIfaceAndImpl.kt b/src/dorkbox/network/serialization/ClassRegistrationIfaceAndImpl.kt index a8a66405..72e6d2eb 100644 --- a/src/dorkbox/network/serialization/ClassRegistrationIfaceAndImpl.kt +++ b/src/dorkbox/network/serialization/ClassRegistrationIfaceAndImpl.kt @@ -31,8 +31,9 @@ internal class ClassRegistrationIfaceAndImpl(val ifaceClass: Class<*>, id = registration.id // override that registration - kryo.register(implClass, serializer, id).id + kryo.register(implClass, serializer, id) } else { + // now register the impl class id = kryo.register(implClass, serializer).id } }