Class GenericWebSocketFrame

java.lang.Object
io.inverno.mod.http.base.internal.ws.GenericWebSocketFrame
All Implemented Interfaces:
WebSocketFrame

public class GenericWebSocketFrame extends Object implements WebSocketFrame

Generic WebSocketFrame implementation.

Since:
1.5
Author:
Jeremy Kuhn
  • Constructor Details

    • GenericWebSocketFrame

      public GenericWebSocketFrame(io.netty.handler.codec.http.websocketx.WebSocketFrame underlyingFrame)

      Creates a generic WebSocket frame.

      The frame type is determined from the specified underlying frame.

      Parameters:
      underlyingFrame - the underlying Netty WebSocket frame
    • GenericWebSocketFrame

      public GenericWebSocketFrame(io.netty.handler.codec.http.websocketx.WebSocketFrame underlyingFrame, WebSocketFrame.Kind kind)

      Creates a generic WebSocket frame.

      This does not verify the specified kind which must correspond to the type of the specified underlying frame.

      Parameters:
      underlyingFrame - the underlying Netty WebSocket frame
      kind - the frame type
  • Method Details

    • getUnderlyingFrame

      public io.netty.handler.codec.http.websocketx.WebSocketFrame getUnderlyingFrame()

      Returns the underlying frame.

      Returns:
      the underlying Netty frame
    • getKind

      public WebSocketFrame.Kind getKind()
      Description copied from interface: WebSocketFrame

      Returns the WebSocket frame type.

      Specified by:
      getKind in interface WebSocketFrame
      Returns:
      a WebSocket frame type
    • isFinal

      public boolean isFinal()
      Description copied from interface: WebSocketFrame

      Determines whether the frame is final.

      Specified by:
      isFinal in interface WebSocketFrame
      Returns:
      true if the frame is final, false otherwise
    • getBinaryData

      public io.netty.buffer.ByteBuf getBinaryData()
      Description copied from interface: WebSocketFrame

      Returns the frame's payload data.

      Specified by:
      getBinaryData in interface WebSocketFrame
      Returns:
      the payload data
    • getTextData

      public String getTextData()
      Description copied from interface: WebSocketFrame

      Returns the frame's payload data as text.

      This basically returns the frame's binary payload encode in UTF-8 as defined by RFC 6455 Section 5.6.

      Specified by:
      getTextData in interface WebSocketFrame
      Returns:
      the payload data as UTF-8 text
    • retain

      public WebSocketFrame retain()
      Description copied from interface: WebSocketFrame

      Increases the reference count of the frame.

      A WebSocket frame is reference counted, increasing the reference count allows to keep the frame into memory.

      Specified by:
      retain in interface WebSocketFrame
      Returns:
      this frame
    • retainedDuplicate

      public WebSocketFrame retainedDuplicate()
      Description copied from interface: WebSocketFrame

      Returns a retained frame which shares the whole region of this frame's data.

      A WebSocket frame is reference counted to optimize memory usage, as a result a frame can only be written once to the WebSocket endpoint (the frame and its data are released once the frame has been sent). Using a retained duplicate allows to create multiple frames that share the same memory and that can be sent to multiple endpoints.

      Specified by:
      retainedDuplicate in interface WebSocketFrame
      Returns:
      a retained WebSocket frame
    • release

      public WebSocketFrame release()
      Description copied from interface: WebSocketFrame

      Decreases the reference count by 1 of the frame and deallocates the frame if the reference count reaches at 0.

      A WebSocket frame is reference counted, it must be released when processed in a final operation in order to release memory.

      Specified by:
      release in interface WebSocketFrame
      Returns:
      this frame
    • refCnt

      public int refCnt()
      Description copied from interface: WebSocketFrame

      Returns the current reference count of the frame.

      If 0, it means the frame has been deallocated and can not be used anymore.

      Specified by:
      refCnt in interface WebSocketFrame
      Returns:
      the reference count