Captive Imagination
September 06, 2010, 08:42:04 AM *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
News: jSeamless 1.0 Beta 7 is Available http://www.jseamless.org
 
   Home   Help Search Calendar Login Register  
Pages: [1]   Go Down
  Print  
Author Topic: Problem on first Connection  (Read 355 times)
0 Members and 1 Guest are viewing this topic.
Creativ
Newbie
*
Offline Offline

Posts: 3


View Profile
« on: December 03, 2009, 10:36:47 AM »

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:
Code:
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:
Quote
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:
Code:
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:
Code:
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
Logged
Tumaini
JGN Developer
Jr. Member
*****
Offline Offline

Posts: 51


View Profile
« Reply #1 on: December 04, 2009, 05:19:12 AM »

Are you using the latest SVN version?
I'm in the process of expanding the sync code to allow for proximity (which should be working now) and other regional functionality.
There was a bug that crept in recently that caused server objects not to be sync'ed.
It should be fixed in the latest update.

I looked into the code you're basing your tests on and didn't really find anything that would explain it.
Though I did find that BasicSyncManager seems to hold only one object (playerBox) which keeps the reference to the last created remote player object. If I'm not mistaken this could create the event where every remote player on a client is using the same reference and so they are referencing the same object (which gets changed every time a new remote player connects).
Logged
Creativ
Newbie
*
Offline Offline

Posts: 3


View Profile
« Reply #2 on: December 04, 2009, 06:14:07 AM »

Hey,

thanks!
I just updated the source code and now it works Smiley

Maybe i can show you a first version of my game in a few weeks.

Dennis
Logged
Pages: [1]   Go Up
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.11 | SMF © 2006-2009, Simple Machines LLC Valid XHTML 1.0! Valid CSS!
Page created in 0.158 seconds with 21 queries.