Interface WebSocketFrame
public interface WebSocketFrame
A WebSocket frame that represents either text or binary data.
A WebSocket message is composed of one or more WebSocket frames.
If there is a just a single frame in the message then a single text or binary frame should be created with final = true.
If there are more than one frames in the message, then the first frame should be a text or binary frame with final = false, followed by one or more continuation frames. The last continuation frame should have final = true.
- Version:
- $Rev: 2080 $, $Date: 2010-01-26 18:04:19 +0900 (Tue, 26 Jan 2010) $
- Author:
- The Netty Project, Trustin Lee, Tim Fox
-
Method Summary
Modifier and TypeMethodDescriptionstatic WebSocketFramebinaryFrame(Buffer data, boolean isFinal) Create a binary WebSocket frame.shortstatic WebSocketFramecontinuationFrame(Buffer data, boolean isFinal) Create a continuation framebooleanisBinary()booleanisClose()booleanbooleanisFinal()booleanisPing()booleanisText()static WebSocketFrameCreate a ping WebSocket frame.static WebSocketFrameCreate a pong WebSocket frame.textData()static WebSocketFrameCreate a text WebSocket frame.type()
-
Method Details
-
binaryFrame
Create a binary WebSocket frame.- Parameters:
data- the data for the frameisFinal- true if it's the final frame in the WebSocket message- Returns:
- the frame
-
textFrame
Create a text WebSocket frame.- Parameters:
str- the string for the frameisFinal- true if it's the final frame in the WebSocket message- Returns:
- the frame
-
pingFrame
Create a ping WebSocket frame. Will be a final frame. There is no option for non final ping frames.- Parameters:
data- the bytes for the frame, may be at most 125 bytes- Returns:
- the frame
-
pongFrame
Create a pong WebSocket frame. Will be a final frame. There is no option for non final pong frames.- Parameters:
data- the bytes for the frame, may be at most 125 bytes- Returns:
- the frame
-
continuationFrame
Create a continuation frame- Parameters:
data- the data for the frameisFinal- true if it's the final frame in the WebSocket message- Returns:
- the frame
-
type
WebSocketFrameType type()- Returns:
- the frame type
-
isText
boolean isText()- Returns:
- whether the frame is a
WebSocketFrameType.TEXTframe
-
isBinary
boolean isBinary()- Returns:
- whether the frame is a
WebSocketFrameType.BINARYframe
-
isContinuation
boolean isContinuation()- Returns:
- whether the frame is a
WebSocketFrameType.CONTINUATIONframe
-
isClose
boolean isClose()- Returns:
- whether the frame is a
WebSocketFrameType.CLOSEframe
-
isPing
boolean isPing()- Returns:
- whether the frame is a
WebSocketFrameType.PINGframe
-
textData
String textData()- Returns:
- the content of this frame as a UTF-8 string and returns the converted string. Only use this for text frames.
-
binaryData
Buffer binaryData()- Returns:
- the data of the frame
-
isFinal
boolean isFinal()- Returns:
- true if this is the final frame.
-
closeStatusCode
short closeStatusCode()- Returns:
- status code of close frame. Only use this for close frames
-
closeReason
String closeReason()- Returns:
- string explaining close reason. Only use this for close frames
-