Class ClientWsFrame

java.lang.Object
io.helidon.websocket.ClientWsFrame
All Implemented Interfaces:
WsFrame

public final class ClientWsFrame extends Object
Frame from a client (always masked).
  • Method Details

    • data

      public static ClientWsFrame data(String text, boolean last)
      Create a text data frame. This method does not split the message into smaller frames if the number of bytes is too high, make sure to use with buffer sizes that are guaranteed to be processed by clients.
      Parameters:
      text - text data content
      last - whether the data is last
      Returns:
      a new client frame
    • data

      public static ClientWsFrame data(BufferData bufferData, boolean last)
      Create a binary data frame. This method does not split the message into smaller frames if the number of bytes is too high, make sure to use with buffer sizes that are guaranteed to be processed by clients.
      Parameters:
      bufferData - binary data content
      last - whether the data is last
      Returns:
      a new client frame
    • control

      public static ClientWsFrame control(WsOpCode opCode, BufferData bufferData)
      Create a new control frame.
      Parameters:
      opCode - operation code of this frame
      bufferData - data of the frame, maximally 125 bytes
      Returns:
      a new client frame
      Throws:
      IllegalArgumentException - in case the length is invalid
    • read

      public static ClientWsFrame read(SocketContext ctx, DataReader dataReader, int maxFrameLength)
      Read client frame from request data.
      Parameters:
      ctx - socket context
      dataReader - data reader to get frame bytes from
      maxFrameLength - maximal length of a frame, to protect memory from too big frames
      Returns:
      a new client frame
      Throws:
      WsCloseException - in case of invalid frame
      RuntimeException - depending on implementation of dataReader
    • masked

      public boolean masked()
      Description copied from interface: WsFrame
      Whether this frame is masked. Server frames must not be masked, client frames must be masked.
      Returns:
      true for masked frames
    • maskingKey

      public int[] maskingKey()
      Description copied from interface: WsFrame
      Masking key, if WsFrame.masked() returns true.
      Returns:
      masking key if available
    • maskedData

      public BufferData maskedData()
      Masked data of this frame, to be sent over the network.
      Returns:
      masked data
    • fin

      public boolean fin()
      Description copied from interface: WsFrame
      Is the end of message (or end of continuation).
      Specified by:
      fin in interface WsFrame
      Returns:
      true if this is a full message, or the last message in a continuation
    • opCode

      public WsOpCode opCode()
      Description copied from interface: WsFrame
      Operation code of this frame.
      Specified by:
      opCode in interface WsFrame
      Returns:
      code of this frame
    • payloadLength

      public long payloadLength()
      Description copied from interface: WsFrame
      Length of the payload bytes.
      Specified by:
      payloadLength in interface WsFrame
      Returns:
      payload length
    • payloadData

      public BufferData payloadData()
      Description copied from interface: WsFrame
      Always unmasked.
      Specified by:
      payloadData in interface WsFrame
      Returns:
      payload bytes
    • isPayload

      public boolean isPayload()
      Description copied from interface: WsFrame
      Helper method to check whether this is a payload frame (text or binary), or a control frame (such as ping, pong, close etc.).
      Specified by:
      isPayload in interface WsFrame
      Returns:
      true for text or binary frames, false for control frames
      See Also:
    • opCode

      public void opCode(WsOpCode opCode)
      Configure the operation code of this frame.
      Parameters:
      opCode - code to use
    • toString

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

      protected static io.helidon.websocket.AbstractWsFrame.FrameHeader readFrameHeader(DataReader reader, int maxFrameLength)
    • readPayload

      protected static BufferData readPayload(DataReader reader, io.helidon.websocket.AbstractWsFrame.FrameHeader header)
    • isPayload

      protected static boolean isPayload(io.helidon.websocket.AbstractWsFrame.FrameHeader header)