public WebSocketFrame(byte[] rawFrame){
  ByteBuffer buffer=ByteBuffer.wrap(rawFrame);
  byte b=buffer.get();
  setFinAndOpCode(b);
  b=buffer.get();
  boolean masked=((b & 0x80) != 0);
  int payloadLength=(byte)(0x7F & b);
  int byteCount=0;
  if (payloadLength == 0X7F) {
    byteCount=8;
  }
 else   if (payloadLength == 0X7E) {
    byteCount=2;
  }
  while (--byteCount > 0) {
    b=buffer.get();
    payloadLength|=(b & 0xFF) << (8 * byteCount);
  }
  byte maskingKey[]=null;
  if (masked) {
    maskingKey=new byte[4];
    buffer.get(maskingKey,0,4);
  }
  this.payload=new byte[payloadLength];
  buffer.get(this.payload,0,payloadLength);
  if (masked) {
    for (int i=0; i < this.payload.length; i++) {
      this.payload[i]^=maskingKey[i % 4];
    }
  }
  return;
}

public WebSocketFrame ( byte [ ] rawFrame ) { ByteBuffer buffer = ByteBuffer . wrap ( rawFrame ) ; byte b = buffer . get ( ) ; setFinAndOpCode ( b ) ; b = buffer . get ( ) ; boolean masked = ( ( b & 0x80 ) != 0 ) ; int payloadLength = ( byte ) ( 0x7F & b ) ; int byteCount = 0 ; if ( payloadLength == 0X7F ) { byteCount = 8 ; } else if ( payloadLength == 0X7E ) { byteCount = 2 ; } while ( -- byteCount > 0 ) { b = buffer . get ( ) ; payloadLength |= ( b & 0xFF ) << ( 8 * byteCount ) ; } byte maskingKey [ ] = null ; if ( masked ) { maskingKey = new byte [ 4 ] ; buffer . get ( maskingKey , 0 , 4 ) ; } this . payload = new byte [ payloadLength ] ; buffer . get ( this . payload , 0 , payloadLength ) ; if ( masked ) { for ( int i = 0 ; i < this . payload . length ; i ++ ) { this . payload [ i ] ^= maskingKey [ i % 4 ] ; } } return ; }
initialise websocketframe from raw data
