Modified to skip registering the message classes if they are

already registered.  This avoids one of the issues of a client
running in the same JVM as a server that already registered these
classes.  This was the easy fix.
cleanup_build_scripts
Paul Speed 9 years ago
parent 2c337123a9
commit 4b2f361026
  1. 19
      jme3-networking/src/main/java/com/jme3/network/service/serializer/ClientSerializerRegistrationsService.java

@ -39,6 +39,8 @@ import com.jme3.network.message.SerializerRegistrationsMessage;
import com.jme3.network.serializing.Serializer;
import com.jme3.network.service.AbstractClientService;
import com.jme3.network.service.ClientServiceManager;
import java.util.logging.Level;
import java.util.logging.Logger;
/**
@ -48,14 +50,21 @@ import com.jme3.network.service.ClientServiceManager;
*/
public class ClientSerializerRegistrationsService extends AbstractClientService
implements MessageListener<Client> {
static final Logger log = Logger.getLogger(SerializerRegistrationsMessage.class.getName());
@Override
protected void onInitialize( ClientServiceManager serviceManager ) {
// Make sure our message type is registered
// This is the minimum we'd need just to be able to register
// the rest... otherwise we can't even receive this message.
Serializer.registerClass(SerializerRegistrationsMessage.class);
Serializer.registerClass(SerializerRegistrationsMessage.Registration.class);
// Make sure our message type is registered if it isn't already
if( Serializer.getSerializer(SerializerRegistrationsMessage.class, false) == null ) {
// This is the minimum we'd need just to be able to register
// the rest... otherwise we can't even receive this message.
Serializer.registerClass(SerializerRegistrationsMessage.class);
Serializer.registerClass(SerializerRegistrationsMessage.Registration.class);
} else {
log.log(Level.INFO, "Skipping registration of SerializerRegistrationsMessage.");
}
// Add our listener for that message type
serviceManager.getClient().addMessageListener(this, SerializerRegistrationsMessage.class);

Loading…
Cancel
Save