Hi,
I'm currently trying to get JGN working, but i got a small problem.
I tried using this example:
http://forum.captiveimagination.com/index.php/topic,661.0.html.
It worked pretty well, but in my game the server should also have a player. So i changed the SyncableServer and added the Server-Player at the end of the class:
serverSyncManager.register(gameServer.getPlayerBox(), new SynchronizeCreateMessage(), NetworkConstants.UPDATE_INTERVALL);
But now i got some weird Problem. The first Client that is trying to connect to the Server can connect to the server and basically everything works, except the box of the Server-Player just stays right in the middle (0,0,0).
If i connect with a second Client everything works just fine, but in the first client the Server-Box still doesn't change his location. The other clients change the position in the first client, it's only the Server-Player that just stays in the middle.
Here is some logging. Maybe it helps:
Connecting!
03.12.2009 17:28:21 com.captiveimagination.jgn.clientserver.JGNClient$1 messageReceived
INFO: JGNClient: playerId was assigned to 0
03.12.2009 17:28:21 com.captiveimagination.jgn.clientserver.JGNClient$1 messageReceived
INFO: JGNClient: playerId was assigned to 0
Create Message
Connected!
03.12.2009 17:28:21 com.captiveimagination.jgn.clientserver.JGNClient connectAndWait
INFO: JGN Connected
03.12.2009 17:28:21 com.jme.scene.Node attachChild
INFO: Child "vehicle1" attached to this node "game: RootNode"
Sent request to server for id
03.12.2009 17:28:21 com.captiveimagination.jgn.clientserver.JGNClient sendToServer
WARNUNG: message is not a playermessage: com.captiveimagination.jgn.synchronization.message.SynchronizeRequestIDMessage@60cf710e
Message Sent: com.captiveimagination.jgn.synchronization.message.SynchronizeRequestIDMessage@11568fb5
Message Received: Receipt certifying:1
Message Received: com.captiveimagination.jgn.synchronization.message.SynchronizeRequestIDMessage@49f4bcf7
Received id from server: 2
And since i changed everything a little bit, here are my Server- and Client-Classes:
Server:
public class Server extends BasicSyncManager {
private JGNServer server = null;
public Server(VerySimpleGame gameServer) throws IOException {
// Initialize networking
InetSocketAddress serverReliable = new InetSocketAddress(InetAddress.getLocalHost(), NetworkConstants.SERVER_TCP_PORT);
InetSocketAddress serverFast = new InetSocketAddress(InetAddress.getLocalHost(), NetworkConstants.SERVER_UDP_PORT);
server = new JGNServer(serverReliable, serverFast);
//Instantiate an instance of a JMEGraphicalController
JMEGraphicalController controller = new JMEGraphicalController();
// Create SynchronizationManager instance for this server
SynchronizationManager serverSyncManager = new SynchronizationManager(server, controller);
serverSyncManager.addSyncObjectManager(this);
JGN.createThread(server).start();
JGN.createThread(serverSyncManager).start();
this.setScene(gameServer.getScene());
serverSyncManager.register(gameServer.getPlayerBox(), new SynchronizeCreateMessage(), NetworkConstants.UPDATE_INTERVALL);
}
public void close() {
try {
server.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
And client:
public class Client extends BasicSyncManager {
private JGNClient client = null;
public Client(VerySimpleGame gameClient) throws Exception {
// Initialize networking
InetSocketAddress serverReliable = new InetSocketAddress(InetAddress.getLocalHost(), NetworkConstants.SERVER_TCP_PORT);
InetSocketAddress serverFast = new InetSocketAddress(InetAddress.getLocalHost(), NetworkConstants.SERVER_UDP_PORT);
// Initialize networking
InetSocketAddress clientReliable = new InetSocketAddress(InetAddress.getLocalHost(), 0);
InetSocketAddress clientFast = new InetSocketAddress(InetAddress.getLocalHost(), 0);
client = new JGNClient(clientReliable, clientFast);
JGN.createThread(client).start();
// Instantiate an instance of a JMEGraphicalController
JMEGraphicalController controller = new JMEGraphicalController();
// Create SynchronizationManager instance for this server
SynchronizationManager clientSyncManager = new SynchronizationManager(client, controller);
clientSyncManager.addSyncObjectManager(this);
JGN.createThread(clientSyncManager).start();
setScene(gameClient.getScene());
// Connect to the server before we register anything
System.out.println("Connecting!");
client.connectAndWait(serverReliable, serverFast, 5000);
System.out.println("Connected!");
client.getServerConnection().getReliableClient().addMessageListener(new MessageListener() {
public void messageCertified(Message message) {
System.out.println("Message Certified: " + message);
}
public void messageFailed(Message message) {
System.out.println("Message Failed: " + message);
}
public void messageReceived(Message message) {
System.out.println("Message Received: " + message);
}
public void messageSent(Message message) {
System.out.println("Message Sent: " + message);
}
});
// Register server vehicle
clientSyncManager.register(gameClient.getPlayerBox(), new SynchronizeCreateMessage(), NetworkConstants.UPDATE_INTERVALL);
}
public void close() {
try {
client.disconnect();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
I hope you can help me.
Dennis