Class Generator


  • public class Generator
    extends java.lang.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 Summary

      Fields 
      Modifier and Type Field Description
      static int MAX_HEADER_LENGTH
      The overhead (maximum) for a framing header.
    • Constructor Summary

      Constructors 
      Constructor Description
      Generator​(org.eclipse.jetty.websocket.api.WebSocketPolicy policy, org.eclipse.jetty.io.ByteBufferPool bufferPool)
      Construct Generator with provided policy and bufferPool
      Generator​(org.eclipse.jetty.websocket.api.WebSocketPolicy policy, org.eclipse.jetty.io.ByteBufferPool bufferPool, boolean validating)
      Construct Generator with provided policy and bufferPool
      Generator​(org.eclipse.jetty.websocket.api.WebSocketPolicy policy, org.eclipse.jetty.io.ByteBufferPool bufferPool, boolean validating, boolean readOnly)
      Construct Generator with provided policy and bufferPool
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void assertFrameValid​(org.eclipse.jetty.websocket.api.extensions.Frame frame)  
      void configureFromExtensions​(java.util.List<? extends org.eclipse.jetty.websocket.api.extensions.Extension> exts)  
      java.nio.ByteBuffer generateHeaderBytes​(org.eclipse.jetty.websocket.api.extensions.Frame frame)  
      void generateHeaderBytes​(org.eclipse.jetty.websocket.api.extensions.Frame frame, java.nio.ByteBuffer buffer)  
      void generateWholeFrame​(org.eclipse.jetty.websocket.api.extensions.Frame frame, java.nio.ByteBuffer buf)
      Generate the whole frame (header + payload copy) into a single ByteBuffer.
      org.eclipse.jetty.io.ByteBufferPool getBufferPool()  
      boolean isRsv1InUse()  
      boolean isRsv2InUse()  
      boolean isRsv3InUse()  
      void setRsv1InUse​(boolean rsv1InUse)  
      void setRsv2InUse​(boolean rsv2InUse)  
      void setRsv3InUse​(boolean rsv3InUse)  
      java.lang.String toString()  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Field Detail

      • 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:
        Constant Field Values
    • Constructor Detail

      • Generator

        public Generator​(org.eclipse.jetty.websocket.api.WebSocketPolicy policy,
                         org.eclipse.jetty.io.ByteBufferPool bufferPool)
        Construct Generator with provided policy and bufferPool
        Parameters:
        policy - the policy to use
        bufferPool - the buffer pool to use
      • Generator

        public Generator​(org.eclipse.jetty.websocket.api.WebSocketPolicy policy,
                         org.eclipse.jetty.io.ByteBufferPool bufferPool,
                         boolean validating)
        Construct Generator with provided policy and bufferPool
        Parameters:
        policy - the policy to use
        bufferPool - the buffer pool to use
        validating - true to enable RFC frame validation
      • Generator

        public Generator​(org.eclipse.jetty.websocket.api.WebSocketPolicy policy,
                         org.eclipse.jetty.io.ByteBufferPool bufferPool,
                         boolean validating,
                         boolean readOnly)
        Construct Generator with provided policy and bufferPool
        Parameters:
        policy - the policy to use
        bufferPool - the buffer pool to use
        validating - true to enable RFC frame validation
        readOnly - true if generator is to treat frames as read-only and not modify them. Useful for debugging purposes, but not generally for runtime use.
    • Method Detail

      • assertFrameValid

        public void assertFrameValid​(org.eclipse.jetty.websocket.api.extensions.Frame frame)
      • configureFromExtensions

        public void configureFromExtensions​(java.util.List<? extends org.eclipse.jetty.websocket.api.extensions.Extension> exts)
      • generateHeaderBytes

        public java.nio.ByteBuffer generateHeaderBytes​(org.eclipse.jetty.websocket.api.extensions.Frame frame)
      • generateHeaderBytes

        public void generateHeaderBytes​(org.eclipse.jetty.websocket.api.extensions.Frame frame,
                                        java.nio.ByteBuffer buffer)
      • generateWholeFrame

        public void generateWholeFrame​(org.eclipse.jetty.websocket.api.extensions.Frame frame,
                                       java.nio.ByteBuffer buf)
        Generate the whole frame (header + payload copy) into a single ByteBuffer.

        Note: This is slow, moves lots of memory around. Only use this if you must (such as in unit testing).

        Parameters:
        frame - the frame to generate
        buf - the buffer to output the generated frame to
      • getBufferPool

        public org.eclipse.jetty.io.ByteBufferPool getBufferPool()
      • setRsv1InUse

        public void setRsv1InUse​(boolean rsv1InUse)
      • setRsv2InUse

        public void setRsv2InUse​(boolean rsv2InUse)
      • setRsv3InUse

        public void setRsv3InUse​(boolean rsv3InUse)
      • isRsv1InUse

        public boolean isRsv1InUse()
      • isRsv2InUse

        public boolean isRsv2InUse()
      • isRsv3InUse

        public boolean isRsv3InUse()
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object