void gatherMessageProtocol ( int maxPos ) throws IOException { try { while ( this . bufferPosition < maxPos ) { byte b = this . buffer [ this . bufferPosition ] ; this . bufferPosition ++ ; if ( gotCR ) { if ( b == NatsConnection . LF ) { this . mode = Mode . PARSE_PROTO ; this . gotCR = false ; break ; } else { throw new IllegalStateException ( "Bad socket data, no LF after CR" ) ; } } else if ( b == NatsConnection . CR ) { this . gotCR = true ; } else { if ( this . msgLinePosition >= this . msgLineChars . length ) { throw new IllegalStateException ( "Protocol line is too long" ) ; } this . msgLineChars [ this . msgLinePosition ] = ( char ) b ; // Assumes ascii, as per protocol doc this . msgLinePosition ++ ; } } } catch ( IllegalStateException | NumberFormatException | NullPointerException ex ) { this . encounteredProtocolError ( ex ) ; } }
Stores the message protocol line in a char buffer that will be grepped for subject reply