throw new IncompleteException( realpacketsize );
byte b1 = buffer.get( /*0*/);
boolean FIN = b1 >> 8 != 0;
byte rsv = (byte) ( ( b1 & ~(byte) 128 ) >> 4 );
if( rsv != 0 )
throw new InvalidFrameException( "bad rsv " + rsv );
byte b2 = buffer.get( /*1*/);
boolean MASK = ( b2 & -128 ) != 0;
int payloadlength = (byte) ( b2 & ~(byte) 128 );
Opcode optcode = toOpcode( (byte) ( b1 & 15 ) );
if( !FIN ) {
if( optcode == Opcode.PING || optcode == Opcode.PONG || optcode == Opcode.CLOSING ) {
throw new InvalidFrameException( "control frames may no be fragmented" );
}
}
if( payloadlength >= 0 && payloadlength <= 125 ) {
} else {
if( optcode == Opcode.PING || optcode == Opcode.PONG || optcode == Opcode.CLOSING ) {
throw new InvalidFrameException( "more than 125 octets" );
}
if( payloadlength == 126 ) {
realpacketsize += 2; // additional length bytes
if( maxpacketsize < realpacketsize )
throw new IncompleteException( realpacketsize );