void notifyNewClientConnected ( Socket socket ) { try { int secure = 0 ; while ( clients . containsKey ( Byte . valueOf ( lastId ) ) ) { lastId ++ ; secure ++ ; final int max = 127 ; if ( secure > max ) { break ; } } // Prepare first data final ClientSocket client = new ClientSocket ( lastId , socket ) ; client . setState ( StateConnection . CONNECTING ) ; client . getOut ( ) . writeByte ( NetworkMessageSystemId . CONNECTING ) ; client . getOut ( ) . writeByte ( client . getId ( ) ) ; client . getOut ( ) . flush ( ) ; // Update list clients . put ( Byte . valueOf ( client . getId ( ) ) , client ) ; clientsNumber ++ ; } catch ( final IOException exception ) { errorNewClientConnected ( exception ) ; } catch ( final LionEngineException exception ) { errorNewClientConnected ( exception ) ; } }
Add a client .