Class Frame

java.lang.Object
org.glassfish.tyrus.core.frame.Frame
Direct Known Subclasses:
TyrusFrame

public class Frame extends Object
WebSocket frame representation.
TODO:
 - masking (isMask is currently ignored)
 - validation
 - payloadLength is limited to int
Author:
Pavel Bucek
  • Constructor Details

    • Frame

      protected Frame(Frame frame)
      Copy constructor.

      Note: this is shallow copy. Payload is *not* copied to new array.

      Parameters:
      frame - copied frame.
  • Method Details

    • isFin

      public boolean isFin()
      Get FIN value.
      Returns:
      true when FIN flag is set, false otherwise.
    • isRsv1

      public boolean isRsv1()
      GET RSV1 value.
      Returns:
      true when RSV1 flag is set, false otherwise.
    • isRsv2

      public boolean isRsv2()
      GET RSV2 value.
      Returns:
      true when RSV2 flag is set, false otherwise.
    • isRsv3

      public boolean isRsv3()
      GET RSV3 value.
      Returns:
      true when RSV3 flag is set, false otherwise.
    • isMask

      public boolean isMask()
      Currently not used.
      Returns:
      not used.
    • getOpcode

      public byte getOpcode()
      Get opcode.
      Returns:
      opcode (4 bit value).
    • getPayloadLength

      public long getPayloadLength()
      Get payload length.
      Returns:
      payload length.
    • getMaskingKey

      public Integer getMaskingKey()
      Get masking key.
      Returns:
      masking key (32 bit value) or null when the frame should not be masked.
    • getPayloadData

      public byte[] getPayloadData()
      Get payload data.

      Changes done to returned array won't be propagated to current Frame instance. If you need to modify payload, you have to create new instance, see Builder#Frame(Frame). Length of returned array will be always same as getPayloadLength().

      Returns:
      payload data.
    • isControlFrame

      public boolean isControlFrame()
      Get information about frame type.
      Returns:
      true when this frame is control (close, ping, pong) frame, false otherwise.
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • builder

      public static Frame.Builder builder()
      Create new Frame.Builder.
      Returns:
      new builder instance.
    • builder

      public static Frame.Builder builder(Frame frame)
      Create new Frame.Builder based on provided frame.
      Parameters:
      frame - frame used as a base for building new frame.
      Returns:
      new builder instance.