As I mentioned in this thread, I’m developing a project with Spidermonkey. My project uses java.util.UUID extensively, and in many cases UUIDs need to be sent between the server and the client. Since Spidermonkey doesn’t natively support those, I made a UUIDSerializer class.
As I mentioned in the other thread, I’m using the Spidermonkey registration service to propagate message registrations from the server to the client. In the absence of finding explicit documentation on this topic, I assumed that a custom class serializer like this would need to be registered on both the client and the server. However, when I place
Serializer.registerClass(UUID.class, new UUIDSerializer());
in both the server and the client network initialization (before any connections are established), the client fails to connect and logs the following stack trace:
May 29, 2017 10:50:01 AM com.jme3.network.base.DefaultClient handleError SEVERE: Termining connection due to unhandled error java.lang.ClassCastException: java.util.UUID cannot be cast to com.jme3.network.Message at com.jme3.network.base.MessageProtocol.createMessage(MessageProtocol.java:181) at com.jme3.network.base.MessageProtocol.addBuffer(MessageProtocol.java:160) at com.jme3.network.base.ConnectorAdapter.run(ConnectorAdapter.java:169)
However, if I comment out the serializer registration on the client (but leave it on the server), the client connects successfully. (I haven’t tested what happens if I attempt to send a message that contains a UUID, however.)
I find it rather odd that the client would fail like this when registering a custom serializer on both the server and client. If using the registration service, is the client reflectively finding and creating an instance of the custom serializer? Am I correct to conclude that the right way to handle custom serializers when using the registration service is to register them only on the server, giving them no special treatment client side?