How does JGN unregister synced objects in FlagRushNetworking?

Hi, sometimes my player isn't unregistered and after that new players who join the game can't see other players. I understand somewhat how the unregistering works. The clientSyncManager.unregister(localPlayer) broadcasts the SynchronizeRemoveMessage which goes to server and server sends it to other clients who apply it in their SyncObjectManager: remove(…).



At some point this automatic unregistering didn't work anymore with my game. So I put the unregistering to the quit method of the BasicGame (which I have extended). But still sometimes the object will still not be unregistered.



    protected void quit() {
        super.quit();
       
        if(server!=null){  
           System.out.println("Server shutting down...");
           ChatMessage chatMessage = new ChatMessage();
         chatMessage.setText("Server shutting down, all connections will be closed. Bye-bye :)");
         server.sendToAll(chatMessage);
         
           //serverSyncManager.shutdown();
         try {            
            server.close();
            
         } catch (IOException e1) {
            // TODO Auto-generated catch block
            e1.printStackTrace();
         }
        }
        if(client!=null){
           System.out.println("Client quitting, unregistering... "+clientSyncManager.unregister(localPlayer));           
                
            
           //clientSyncManager.shutdown();
         try {
            client.close();
         } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
         }
        }
       
        System.exit(0);
    }





But in FlagrushNetworking I dont see anywhere clientSyncManager.unregister(localPlayer)  called, but the objects get properly unregistered when i press ESC. Where is it called when connection is closed?



When connection is lost with that client it automatically removes them.  Dig a little deeper and you'll start to understand…at first glance the synchronization system can look like magic. :slight_smile: