c = new Connection(channels.size()); log.log( Level.FINE, "Registering client for endpoint, pass 1:{0}.", p ); } else { c.setChannel(channel, p); log.log( Level.FINE, "Setting up channel:{0}", channel ); c.close( "Server client mismatch, server:" + getGameName() + " v" + getVersion() + " client:" + m.getGameName() + " v" + m.getVersion() ); return; c.send(cim); if( c.isComplete() ) { if( connections.put( c.getId(), c ) == null ) { m.setId( addedConnection.getId() ); m.setReliable(true); addedConnection.send(m); m.setId(-1); m.setReliable(true); addedConnection.send(m);
connections.remove( removed.getId() ); removed.closeConnection();
protected void removeConnecting( Endpoint p ) { // No easy lookup for connecting Connections // from endpoint. for( Map.Entry<Long,Connection> e : connecting.entrySet() ) { if( e.getValue().hasEndpoint(p) ) { connecting.remove(e.getKey()); return; } } }
c = new Connection(); log.log( Level.FINE, "Registering client for endpoint, pass 1:{0}.", p ); } else { c.close( "Server client mismatch, server:" + getGameName() + " v" + getVersion() + " client:" + m.getGameName() + " v" + m.getVersion() ); return; if( connections.put( c.getId(), c ) == null ) { m.setId( addedConnection.getId() ); m.setReliable(true); addedConnection.send(m);
c = new Connection(channels.size()); log.log( Level.FINE, "Registering client for endpoint, pass 1:{0}.", p ); } else { c.setChannel(channel, p); log.log( Level.FINE, "Setting up channel:{0}", channel ); c.close( "Server client mismatch, server:" + getGameName() + " v" + getVersion() + " client:" + m.getGameName() + " v" + m.getVersion() ); return; c.send(cim); if( c.isComplete() ) { if( connections.put( c.getId(), c ) == null ) { m.setId( addedConnection.getId() ); m.setReliable(true); addedConnection.send(m); m.setId(-1); m.setReliable(true); addedConnection.send(m);
connections.remove( removed.getId() ); removed.closeConnection();
protected void connectionClosed( Endpoint p ) { log.log( Level.INFO, "Connection closed:{0}.", p ); // Try to find the endpoint in all ways that it might // exist. Note: by this point the channel is closed // already. // Also note: this method will be called twice per // HostedConnection if it has two endpoints. Connection removed = null; synchronized( this ) { // Just in case the endpoint was still connecting connecting.values().remove(p); // And the regular management removed = (Connection)endpointConnections.remove(p); if( removed != null ) { connections.remove( removed.getId() ); } } // Better not to fire events while we hold a lock // so always do this outside the synch block. if( removed != null ) { log.log( Level.INFO, "Client closed:{0}.", removed ); removed.closeConnection(); } }
@Override public void close( String reason ) { // Send a reason DisconnectMessage m = new DisconnectMessage(); m.setType( DisconnectMessage.KICK ); m.setReason( reason ); m.setReliable( true ); send( m ); // Just close the reliable endpoint // fast will be cleaned up as a side-effect // when closeConnection() is called by the // connectionClosed() endpoint callback. if( channels[CH_RELIABLE] != null ) { // Close with flush so we make sure our // message gets out channels[CH_RELIABLE].close(true); } }
public void close( String reason ) { // Send a reason DisconnectMessage m = new DisconnectMessage(); m.setType( DisconnectMessage.KICK ); m.setReason( reason ); m.setReliable( true ); send( m ); // Just close the reliable endpoint // fast will be cleaned up as a side-effect // when closeConnection() is called by the // connectionClosed() endpoint callback. if( reliable != null ) { // Close with flush so we make sure our // message gets out reliable.close(true); } }
protected void removeConnecting( Endpoint p ) { // No easy lookup for connecting Connections // from endpoint. for( Map.Entry<Long,Connection> e : connecting.entrySet() ) { if( e.getValue().hasEndpoint(p) ) { connecting.remove(e.getKey()); return; } } }
@Override public void close( String reason ) { // Send a reason DisconnectMessage m = new DisconnectMessage(); m.setType( DisconnectMessage.KICK ); m.setReason( reason ); m.setReliable( true ); send( m ); // Just close the reliable endpoint // fast will be cleaned up as a side-effect // when closeConnection() is called by the // connectionClosed() endpoint callback. if( channels[CH_RELIABLE] != null ) { // Close with flush so we make sure our // message gets out channels[CH_RELIABLE].close(true); } }