Captive Imagination
July 31, 2010, 11:48:23 PM *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
News: Hosting change completed. Please send an e-mail to support@captiveimagination.com if you have any problems.
 
   Home   Help Search Calendar Login Register  
Pages: [1]   Go Down
  Print  
Author Topic: Synchronizing Multiple Objects Per Client  (Read 796 times)
0 Members and 1 Guest are viewing this topic.
Eggsworth
Newbie
*
Offline Offline

Posts: 15


View Profile
« on: October 29, 2009, 01:42:35 PM »

Hi, sorry if this is a little dumb of a question.

Basically each client which connects should register a dynamicphysicsnode and a node.

individually, (by commenting out the others code) they each work. but together, i get some kind of failed thread error on the server.

here is how I am doing it on both the client and server

Code:

// Instantiate an instance of a JMEGraphicalController
JMEPhysicsGraphicalController physicscontroller = new JMEPhysicsGraphicalController();
JMEGraphicalController graphicscontroller = new JMEGraphicalController();
PhysicsSync physicssyncer = new PhysicsSync();
Syncer2 graphicalsyncer = new Syncer2();
// Create SynchronizationManager instance for this server
SynchronizationManager physicsserverSyncManager = new SynchronizationManager(client, physicscontroller);
SynchronizationManager graphicalserverSyncManager = new SynchronizationManager(client, graphicscontroller);
physicsserverSyncManager.addSyncObjectManager(physicssyncer);
graphicalserverSyncManager.addSyncObjectManager(graphicalsyncer);

JGN.createThread(physicsserverSyncManager).start();
JGN.createThread(graphicalserverSyncManager).start();


while (app.ingamestate == null) {
try {
System.out.println("null line 59");
Thread.sleep(100);
} catch(Exception exc) {
exc.printStackTrace();
}
}



Node player2 = app.ingamestate.getPlayer2();
DynamicPhysicsNode player = app.ingamestate.getPlayer1();
Node rootNode = app.ingamestate.getrootNode();

physicssyncer.setScene(rootNode);
graphicalsyncer.setScene(rootNode);

// Connect to the server before we register anything
System.out.println("Connecting!");
client.connectAndWait(serverReliable, serverFast, 1000);
System.out.println("Connected!");


// Register server vehicle
System.out.println("register player");


// Register server vehicle
physicsserverSyncManager.register(player, new SynchronizeCreateMessage(), 50);
graphicalserverSyncManager.register(player2, new SynchronizeCreateMessage(), 50);

I build them each individually and start each their own thread. am I doing this inappropriately? because i cant seem to get it to work.

Thanks for the help.
« Last Edit: October 29, 2009, 01:57:14 PM by Eggsworth » Logged
darkfrog
Administrator
Inspired Imagination
*****
Offline Offline

Posts: 2650


View Profile
« Reply #1 on: October 29, 2009, 03:02:42 PM »

what's the stack trace look like?
Logged
Eggsworth
Newbie
*
Offline Offline

Posts: 15


View Profile
« Reply #2 on: October 29, 2009, 03:39:01 PM »

i cant get a reliable look at the console, but from what i can see the only visible error i get is when i try to connect a second client

Code:
Oct 29, 2009 1:39:00 PM com.captiveimagination.jgn.clientserver.JGNClient connectAndWait
WARNING: Connection to reliableRemoteAddress failed.
Exception in thread "main" java.io.IOException: Connection to reliableRemoteAddress failed.
at com.captiveimagination.jgn.clientserver.JGNClient.connectAndWait(JGNClient.java:347)
at Multi_Sync.MultiSyncClient.<init>(MultiSyncClient.java:84)
at Multi_Sync.MultiSyncClient.main(MultiSyncClient.java:132)

if i comment out one of the register(syncobject), this does not happen.

ill try to see if i can get my hand on more errors..
Logged
Eggsworth
Newbie
*
Offline Offline

Posts: 15


View Profile
« Reply #3 on: October 29, 2009, 07:55:39 PM »

ah, this error was hard to grab because the console would just switch back to the console for the client

here is the error that the server displays when the first client connects

Code:
Server provided id: 1
Oct 29, 2009 5:55:48 PM com.captiveimagination.jgn.DefaultUncaughtExceptionHandler uncaughtException
SEVERE: Uncaught exception: Terminating Thread.
java.lang.NullPointerException
at com.captiveimagination.jgn.synchronization.SynchronizationManager.messageReceived(SynchronizationManager.java:428)
at com.captiveimagination.jgn.MessageServer.sendToListener(MessageServer.java:461)
at com.captiveimagination.jgn.MessageServer.notifyIncoming(MessageServer.java:492)
at com.captiveimagination.jgn.MessageServer.updateEvents(MessageServer.java:379)
at com.captiveimagination.jgn.clientserver.JGNServer.updateEvents(JGNServer.java:176)
at com.captiveimagination.jgn.clientserver.JGNServer.update(JGNServer.java:161)
at com.captiveimagination.jgn.UpdatableRunnable.run(JGN.java:437)
at java.lang.Thread.run(Thread.java:619)
Oct 29, 2009 5:55:48 PM com.captiveimagination.jgn.UpdatableRunnable run
INFO: JGN update thread 16 terminated

so ide take it that it has something to do with syncmessages on the server?

basically, for the second syncobjectmanager, if i initiate it on the client and server, it throws that error.
Logged
Tumaini
JGN Developer
Jr. Member
*****
Offline Offline

Posts: 51


View Profile
« Reply #4 on: October 30, 2009, 10:09:01 AM »

I'm not sure what it says on line 428 in your version of SynchronizationManager.java, but it seems you are creating two SynchronizationManager's with the 2-args constructor, which would give them both an id of -1.
Perhaps the program is looking in the wrong sync manager list for SyncWrapper objects?
You could try instantiating your sync manager's with the 3-args constructor:

SynchronizationManager physicsserverSyncManager = new SynchronizationManager(client, physicscontroller, (short)1);
SynchronizationManager graphicalserverSyncManager = new SynchronizationManager(client, graphicscontroller, (short)2);

I've not used two sync manager's at once myself, so I'm not quite sure how the id's are handled, but when it's sync'ing, it uses the id of the manager to see where the object is to be found.
Logged
Eggsworth
Newbie
*
Offline Offline

Posts: 15


View Profile
« Reply #5 on: October 30, 2009, 01:19:46 PM »

you sir are awesome.

thank you, this solved my problem! Smiley
Logged
Eggsworth
Newbie
*
Offline Offline

Posts: 15


View Profile
« Reply #6 on: October 30, 2009, 01:41:01 PM »

So here is a package which includes

Gamestates
Chat System (mimiced from JGN.chat) using GBUI
Synchronized Node and DynamicPhysicsNode at the same time

all wrapped up in one game!
hope this can help someone out

http://www.mediafire.com/?sharekey=50b53b0d07548ae4e5c3dee5769931ecf2e2f198f26f2a07f7e866bfb1230ce0
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.188 seconds with 20 queries.