Class GenericWebSocketFrame
- All Implemented Interfaces:
WebSocketFrame
Generic WebSocketFrame implementation.
- Since:
- 1.5
- Author:
- Jeremy Kuhn
-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from interface io.inverno.mod.http.base.ws.WebSocketFrame
WebSocketFrame.Factory, WebSocketFrame.Kind -
Constructor Summary
ConstructorsConstructorDescriptionGenericWebSocketFrame(io.netty.handler.codec.http.websocketx.WebSocketFrame underlyingFrame) Creates a generic WebSocket frame.GenericWebSocketFrame(io.netty.handler.codec.http.websocketx.WebSocketFrame underlyingFrame, WebSocketFrame.Kind kind) Creates a generic WebSocket frame. -
Method Summary
Modifier and TypeMethodDescriptionio.netty.buffer.ByteBufReturns the frame's payload data.getKind()Returns the WebSocket frame type.Returns the frame's payload data as text.io.netty.handler.codec.http.websocketx.WebSocketFrameReturns the underlying frame.booleanisFinal()Determines whether the frame is final.intrefCnt()Returns the current reference count of the frame.release()Decreases the reference count by1of the frame and deallocates the frame if the reference count reaches at0.retain()Increases the reference count of the frame.Returns a retained frame which shares the whole region of this frame's data.
-
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 framekind- 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
Description copied from interface:WebSocketFrameReturns the WebSocket frame type.
- Specified by:
getKindin interfaceWebSocketFrame- Returns:
- a WebSocket frame type
-
isFinal
public boolean isFinal()Description copied from interface:WebSocketFrameDetermines whether the frame is final.
- Specified by:
isFinalin interfaceWebSocketFrame- Returns:
- true if the frame is final, false otherwise
-
getBinaryData
public io.netty.buffer.ByteBuf getBinaryData()Description copied from interface:WebSocketFrameReturns the frame's payload data.
- Specified by:
getBinaryDatain interfaceWebSocketFrame- Returns:
- the payload data
-
getTextData
Description copied from interface:WebSocketFrameReturns 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:
getTextDatain interfaceWebSocketFrame- Returns:
- the payload data as UTF-8 text
-
retain
Description copied from interface:WebSocketFrameIncreases 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:
retainin interfaceWebSocketFrame- Returns:
- this frame
-
retainedDuplicate
Description copied from interface:WebSocketFrameReturns 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:
retainedDuplicatein interfaceWebSocketFrame- Returns:
- a retained WebSocket frame
-
release
Description copied from interface:WebSocketFrameDecreases the reference count by
1of the frame and deallocates the frame if the reference count reaches at0.A WebSocket frame is reference counted, it must be released when processed in a final operation in order to release memory.
- Specified by:
releasein interfaceWebSocketFrame- Returns:
- this frame
-
refCnt
public int refCnt()Description copied from interface:WebSocketFrameReturns the current reference count of the frame.
If
0, it means the frame has been deallocated and can not be used anymore.- Specified by:
refCntin interfaceWebSocketFrame- Returns:
- the reference count
-