connection = c; connection.open();  connection.addMoveReceiver(worldUpdater); connection.addConnectionListener(this);   modelRoot.getUserMessageLogger().println (Resources.get("Attempting to authenticate player: ") + player.getName()); authenticated = false; connection.sendCommand(new AddPlayerCommand(player, player.sign())); synchronized (authMutex) { if (!authenticated) { modelRoot.getUserMessageLogger().println (Resources.get("Waiting for authentication"));  try { authMutex.wait(); } catch (InterruptedException e) {  }  if (!authenticated) { throw new GeneralSecurityException("Server rejected " + "attempt to authenticate"); } } }
    private synchronized void setConnectionImpl(ConnectionToServer c)        throws IOException, GeneralSecurityException {        if (gameLoop != null) {            gameLoop.stop();        }        if (connection != null) {            closeConnection();            connection.removeMoveReceiver(worldUpdater);            connection.removeConnectionListener(this);        }        /* grab the lock on the WorldUpdater in order to prevent any moves from         * the server being lost whilst we plumb it in */    //    synchronized (worldUpdater) {            connection = c;            connection.open();            connection.addMoveReceiver(worldUpdater);            connection.addConnectionListener(this);	    /* attempt to authenticate the player */	    modelRoot.getUserMessageLogger().println		(Resources.get("Attempting to authenticate player: ") +		 player.getName());	    authenticated = false;	    connection.sendCommand(new AddPlayerCommand(player, player.sign()));	    synchronized (authMutex) {		if (!authenticated) {		    modelRoot.getUserMessageLogger().println			(Resources.get("Waiting for authentication"));		    try {			authMutex.wait();		    } catch (InterruptedException e) {			//ignore		    }		    if (!authenticated) {			throw new GeneralSecurityException("Server rejected " +				"attempt to authenticate");		    }		}	    } // synchronized (authMutex)	    	synchronized (worldUpdater) {            world = connection.loadWorldFromServer();            /* plumb in a new Move Executer */            moveExecuter = new NonAuthoritativeMoveExecuter(world,                    moveReceiver, modelRoot);            worldUpdater.setMoveReceiver(moveExecuter);            uncommittedReceiver = moveExecuter.getUncommittedMoveReceiver();            ((NonAuthoritativeMoveExecuter.PendingQueue)uncommittedReceiver).addMoveReceiver(connection);        }        /* start a new game loop */	gameLoop = new GameLoop(guiRoot.getScreenHandler(),		moveExecuter);	/* send a command to set up server-specific resources */	connection.sendCommand(new ResourceBundleManager.GetResourceCommand		("org.railz.data.l10n.server", Locale.getDefault()));	playerConfirmed();    }