private void handleCommand ( byte b ) throws IOException { if ( b == SE ) { telnetCommand += ( char ) b ; handleNegotiation ( ) ; reset ( ) ; } else if ( isWill || isDo ) { if ( isWill && b == TERMINAL_TYPE ) { socketChannel . write ( ByteBuffer . wrap ( new byte [ ] { IAC , SB , TERMINAL_TYPE , ECHO , IAC , SE } ) ) ; } else if ( b != ECHO && b != GA && b != NAWS ) { telnetCommand += ( char ) b ; socketChannel . write ( ByteBuffer . wrap ( telnetCommand . getBytes ( ) ) ) ; } reset ( ) ; } else if ( isWont || isDont ) { telnetCommand += ( char ) b ; socketChannel . write ( ByteBuffer . wrap ( telnetCommand . getBytes ( ) ) ) ; reset ( ) ; } else if ( isSb ) { telnetCommand += ( char ) b ; } }
Handle telnet command