Package org.java_websocket.exceptions

Examples of org.java_websocket.exceptions.InvalidDataException


    try {
      bytes.mark();
      s = decode.decode( bytes ).toString();
      bytes.reset();
    } catch ( CharacterCodingException e ) {
      throw new InvalidDataException( CloseFrame.NO_UTF8, e );
    }
    return s;
  }
View Full Code Here


    return translateHandshakeHttp( buf, role );
  }

  public int checkAlloc( int bytecount ) throws LimitExedeedException , InvalidDataException {
    if( bytecount < 0 )
      throw new InvalidDataException( CloseFrame.PROTOCOL_ERROR, "Negative count" );
    return bytecount;
  }
View Full Code Here

  @Override
  public List<Framedata> translateFrame( ByteBuffer buffer ) throws InvalidDataException {
    List<Framedata> frames = translateRegularFrame( buffer );
    if( frames == null ) {
      throw new InvalidDataException( CloseFrame.PROTOCOL_ERROR );
    }
    return frames;
  }
View Full Code Here

          wsl.onWebsocketPong( this, f );
          continue;
        } else if( !fin || curop == Opcode.CONTINUOUS ) {
          if( curop != Opcode.CONTINUOUS ) {
            if( current_continuous_frame_opcode != null )
              throw new InvalidDataException( CloseFrame.PROTOCOL_ERROR, "Previous continuous frame sequence not completed." );
            current_continuous_frame_opcode = curop;
          } else if( fin ) {
            if( current_continuous_frame_opcode == null )
              throw new InvalidDataException( CloseFrame.PROTOCOL_ERROR, "Continuous frame sequence was not started." );
            current_continuous_frame_opcode = null;
          } else if( current_continuous_frame_opcode == null ) {
            throw new InvalidDataException( CloseFrame.PROTOCOL_ERROR, "Continuous frame sequence was not started." );
          }
          try {
            wsl.onWebsocketMessageFragment( this, f );
          } catch ( RuntimeException e ) {
            wsl.onWebsocketError( this, e );
          }

        } else if( current_continuous_frame_opcode != null ) {
          throw new InvalidDataException( CloseFrame.PROTOCOL_ERROR, "Continuous frame sequence not completed." );
        } else if( curop == Opcode.TEXT ) {
          try {
            wsl.onWebsocketMessage( this, Charsetfunctions.stringUtf8( f.getPayloadData() ) );
          } catch ( RuntimeException e ) {
            wsl.onWebsocketError( this, e );
          }
        } else if( curop == Opcode.BINARY ) {
          try {
            wsl.onWebsocketMessage( this, f.getPayloadData() );
          } catch ( RuntimeException e ) {
            wsl.onWebsocketError( this, e );
          }
        } else {
          throw new InvalidDataException( CloseFrame.PROTOCOL_ERROR, "non control or continious frame expected" );
        }
      }
    } catch ( InvalidDataException e1 ) {
      wsl.onWebsocketError( this, e1 );
      close( e1 );
View Full Code Here

      code = CloseFrame.NOCODE;
      m = "";
    }
    if( code == CloseFrame.NOCODE ) {
      if( 0 < m.length() ) {
        throw new InvalidDataException( PROTOCOL_ERROR, "A close frame must have a closecode if it has a reason" );
      }
      return;// empty payload
    }

    byte[] by = Charsetfunctions.utf8Bytes( m );
View Full Code Here

TOP

Related Classes of org.java_websocket.exceptions.InvalidDataException

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.