Package 

Class WebSocketFrame

    • Constructor Detail

      • WebSocketFrame

        WebSocketFrame(byte opcode, boolean fin, Array<byte> payload)
        Initialise a new WebSocketFrame
        Parameters:
        opcode - WebSocket Opcode
        fin - If it's final
        payload - The payload
      • WebSocketFrame

        WebSocketFrame(Array<byte> rawFrame)
        Initialise WebSocketFrame from raw Data
        Parameters:
        rawFrame - The raw byte buffer
      • WebSocketFrame

        WebSocketFrame(InputStream input)
        Takes an input stream and parses it into a Websocket frame.
        Parameters:
        input - The incoming InputStream
    • Method Detail

      • encodeFrame

         Array<byte> encodeFrame()

        Encodes the this WebSocketFrame into a byte array.

      • appendLengthAndMask

         static void appendLengthAndMask(ByteBuffer buffer, int length, Array<byte> mask)

        Appends the Length and Mask to the buffer

        Parameters:
        buffer - the outgoing ByteBuffer
        length - the length of the frame
        mask - The WebSocket Mask
      • appendFinAndOpCode

         static void appendFinAndOpCode(ByteBuffer buffer, byte opcode, boolean fin)

        Appends the Fin flag and the OpCode

        Parameters:
        buffer - The outgoing buffer
        opcode - The Websocket OpCode
        fin - if this is a final frame
      • generateMaskingKey

         static Array<byte> generateMaskingKey()

        Generates a random masking key Nothing super secure, but enough for websockets.