Package org.java_websocket.exceptions

Examples of org.java_websocket.exceptions.InvalidFrameException


      frames = readyframes;
      readingState = true;
      if( currentFrame == null )
        currentFrame = ByteBuffer.allocate( 2 );
      else {
        throw new InvalidFrameException();
      }
      if( buffer.remaining() > currentFrame.remaining() ) {
        throw new InvalidFrameException();
      } else {
        currentFrame.put( buffer );
      }
      if( !currentFrame.hasRemaining() ) {
        if( Arrays.equals( currentFrame.array(), closehandshake ) ) {
          frames.add( new CloseFrameBuilder( CloseFrame.NORMAL ) );
          return frames;
        }
        else{
          throw new InvalidFrameException();
        }
      } else {
        readyframes = new LinkedList<Framedata>();
        return frames;
      }
View Full Code Here


    while ( buffer.hasRemaining() ) {
      byte newestByte = buffer.get();
      if( newestByte == START_OF_FRAME ) { // Beginning of Frame
        if( readingState )
          throw new InvalidFrameException( "unexpected START_OF_FRAME" );
        readingState = true;
      } else if( newestByte == END_OF_FRAME ) { // End of Frame
        if( !readingState )
          throw new InvalidFrameException( "unexpected END_OF_FRAME" );
        // currentFrame will be null if END_OF_FRAME was send directly after
        // START_OF_FRAME, thus we will send 'null' as the sent message.
        if( this.currentFrame != null ) {
          currentFrame.flip();
          FramedataImpl1 curframe = new FramedataImpl1();
View Full Code Here

        return Opcode.PING;
      case 10:
        return Opcode.PONG;
        // 11-15 are not yet defined
      default :
        throw new InvalidFrameException( "unknow optcode " + (short) opcode );
    }
  }
View Full Code Here

      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 );
View Full Code Here

      bb.putShort( payload.getShort() );
      bb.position( 0 );
      code = bb.getInt();

      if( code == CloseFrame.ABNORMAL_CLOSE || code == CloseFrame.TLS_ERROR || code == CloseFrame.NOCODE || code > 4999 || code < 1000 || code == 1004 ) {
        throw new InvalidFrameException( "closecode must not be sent over the wire: " + code );
      }
    }
    payload.reset();
  }
View Full Code Here

      int mark = b.position();// because stringUtf8 also creates a mark
      try {
        b.position( b.position() + 2 );
        reason = Charsetfunctions.stringUtf8( b );
      } catch ( IllegalArgumentException e ) {
        throw new InvalidFrameException( e );
      } finally {
        b.position( mark );
      }
    }
  }
View Full Code Here

TOP

Related Classes of org.java_websocket.exceptions.InvalidFrameException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.