private void receiveConnecting ( ClientSocket client , DataInputStream buffer , byte from , StateConnection expected ) throws IOException { if ( ServerImpl . checkValidity ( client , from , expected ) ) { // Receive the name final byte [ ] name = new byte [ buffer . readByte ( ) ] ; if ( buffer . read ( name ) == - 1 ) { throw new IOException ( "Unable to read client name !" ) ; } client . setName ( new String ( name , NetworkMessage . CHARSET ) ) ; // Send new state client . setState ( StateConnection . CONNECTED ) ; client . getOut ( ) . writeByte ( NetworkMessageSystemId . CONNECTED ) ; client . getOut ( ) . writeByte ( client . getId ( ) ) ; client . getOut ( ) . writeByte ( clientsNumber - 1 ) ; // Send the list of other clients for ( final ClientSocket other : clients . values ( ) ) { if ( other . getId ( ) != from ) { ServerImpl . writeIdAndName ( client , other . getId ( ) , other . getName ( ) ) ; } } // Send message of the day if has if ( messageOfTheDay != null ) { final byte [ ] motd = messageOfTheDay . getBytes ( NetworkMessage . CHARSET ) ; client . getOut ( ) . writeByte ( motd . length ) ; client . getOut ( ) . write ( motd ) ; } // Send client . getOut ( ) . flush ( ) ; } }
Update the receive connecting state .