java.lang.Object
org.eclipse.jetty.websocket.core.internal.Generator

public class Generator extends Object
Generating a frame in WebSocket land.
    0                   1                   2                   3
    0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
   +-+-+-+-+-------+-+-------------+-------------------------------+
   |F|R|R|R| opcode|M| Payload len |    Extended payload length    |
   |I|S|S|S|  (4)  |A|     (7)     |             (16/64)           |
   |N|V|V|V|       |S|             |   (if payload len==126/127)   |
   | |1|2|3|       |K|             |                               |
   +-+-+-+-+-------+-+-------------+ - - - - - - - - - - - - - - - +
   |     Extended payload length continued, if payload len == 127  |
   + - - - - - - - - - - - - - - - +-------------------------------+
   |                               |Masking-key, if MASK set to 1  |
   +-------------------------------+-------------------------------+
   | Masking-key (continued)       |          Payload Data         |
   +-------------------------------- - - - - - - - - - - - - - - - +
   :                     Payload Data continued ...                :
   + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +
   |                     Payload Data continued ...                |
   +---------------------------------------------------------------+
 
  • Field Details

    • MAX_HEADER_LENGTH

      public static final int MAX_HEADER_LENGTH
      The overhead (maximum) for a framing header. Assuming a maximum sized payload with masking key.
      See Also:
  • Constructor Details

    • Generator

      public Generator()
  • Method Details

    • generateWholeFrame

      public void generateWholeFrame(Frame frame, ByteBuffer buffer)
      Generate the whole frame (header + payload copy) into a single ByteBuffer.
      Parameters:
      frame - the frame to generate.
      buffer - the buffer to output the generated frame to.
    • generateHeader

      public void generateHeader(Frame frame, ByteBuffer buffer)
      Generate the header bytes of a frame into a single ByteBuffer.
      Parameters:
      frame - the frame to generate.
      buffer - the buffer to output the generated frame to.
    • generatePayload

      public void generatePayload(Frame frame, ByteBuffer buffer)
      Generate the payload of a frame into a single ByteBuffer, if the frame has a mask the payload will be masked as it is copied to the output buffer.
      Parameters:
      frame - the frame to generate.
      buffer - the buffer to output the generated frame to.