Package com.wowza.wms.websocket.model
Class WebSocketMessage
- Object
- 
- com.wowza.wms.websocket.model.WebSocketMessage
 
- 
 public class WebSocketMessage extends Object
- 
- 
Field SummaryFields Modifier and Type Field Description static StringDEFAULT_CLOSE_REASONstatic intHEADER_SIZE_CONTROLFRAMEstatic intMASK_SIZEstatic intOPCODE_BINARYstatic intOPCODE_CLOSEstatic intOPCODE_CONTINUATIONstatic intOPCODE_PINGstatic intOPCODE_PONGstatic intOPCODE_TEXTstatic intOPCODE_UNKNOWN
 - 
Constructor SummaryConstructors Constructor Description WebSocketMessage()WebSocketMessage(int type)WebSocketMessage(int type, boolean bufferIncludesHeader, byte[] buffer)WebSocketMessage(int type, boolean bufferIncludesHeader, byte[] buffer, int offset, int len)
 - 
Method SummaryAll Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddBuffer(byte[] buffer, int offset, int len, boolean fragmented)Used internally to add read TCP bytes into current pending messagestatic WebSocketMessagecreateMessageBinary(boolean mask, byte[] buffer)Create binary messagestatic WebSocketMessagecreateMessageBinary(boolean mask, byte[] buffer, int offset, int len)Create binary messagestatic WebSocketMessagecreateMessageBinary(boolean mask, com.wowza.util.IFasterByteArrayOutputStream buffer, int offset, int len)Create binary messagestatic WebSocketMessagecreateMessageClose(boolean mask, int reasonCode, String reasonStr)Create a close messagestatic WebSocketMessagecreateMessagePing(boolean mask)Create a ping message (body will be 8-byte UTC in millseconds)static WebSocketMessagecreateMessagePing(boolean mask, byte[] body)Create ping messagestatic WebSocketMessagecreateMessagePong(boolean mask, WebSocketMessage messagePing)Create pong messagestatic WebSocketMessagecreateMessageText(boolean mask, String messageStr)Create text messagebyte[]getBuffer()Get the raw binary message data (also need offset and len)intgetCloseReason()If close message, get the close reasonStringgetCloseReasonStr()If close message, get the close reason strintgetLen()Get len of message buffer dataintgetOffset()Get offset into message bufferintgetType()Get message type, see OPCODE_*StringgetValueString()If text message, get body as stringbooleanisBinary()Is binary messagebooleanisControlMessage()Is message a control messagebooleanisText()Is message text messagelongsendMessage(com.wowza.util.IFasterByteArrayWriteReference out)Internal method to send message over TCP connectionvoidsetType(int type)Set message type, see OPCODE_*StringtoString()Get message as a string (use getValueString() to get the body value of text messages)
 
- 
- 
- 
Field Detail- 
DEFAULT_CLOSE_REASONpublic static final String DEFAULT_CLOSE_REASON - See Also:
- Constant Field Values
 
 - 
HEADER_SIZE_CONTROLFRAMEpublic static final int HEADER_SIZE_CONTROLFRAME - See Also:
- Constant Field Values
 
 - 
MASK_SIZEpublic static final int MASK_SIZE - See Also:
- Constant Field Values
 
 - 
OPCODE_UNKNOWNpublic static final int OPCODE_UNKNOWN - See Also:
- Constant Field Values
 
 - 
OPCODE_CONTINUATIONpublic static final int OPCODE_CONTINUATION - See Also:
- Constant Field Values
 
 - 
OPCODE_TEXTpublic static final int OPCODE_TEXT - See Also:
- Constant Field Values
 
 - 
OPCODE_BINARYpublic static final int OPCODE_BINARY - See Also:
- Constant Field Values
 
 - 
OPCODE_CLOSEpublic static final int OPCODE_CLOSE - See Also:
- Constant Field Values
 
 - 
OPCODE_PINGpublic static final int OPCODE_PING - See Also:
- Constant Field Values
 
 - 
OPCODE_PONGpublic static final int OPCODE_PONG - See Also:
- Constant Field Values
 
 
- 
 - 
Constructor Detail- 
WebSocketMessagepublic WebSocketMessage() 
 - 
WebSocketMessagepublic WebSocketMessage(int type) 
 - 
WebSocketMessagepublic WebSocketMessage(int type, boolean bufferIncludesHeader, byte[] buffer)
 - 
WebSocketMessagepublic WebSocketMessage(int type, boolean bufferIncludesHeader, byte[] buffer, int offset, int len)
 
- 
 - 
Method Detail- 
createMessagePingpublic static WebSocketMessage createMessagePing(boolean mask) Create a ping message (body will be 8-byte UTC in millseconds)- Parameters:
- mask- true, to mask message
- Returns:
- WebSocketMessage
 
 - 
createMessagePingpublic static WebSocketMessage createMessagePing(boolean mask, byte[] body) Create ping message- Parameters:
- mask- true, to mask message
- body- bytes to include as body of message
- Returns:
- WebSocketMessage
 
 - 
createMessagePongpublic static WebSocketMessage createMessagePong(boolean mask, WebSocketMessage messagePing) Create pong message- Parameters:
- mask- true, to mask message
- messagePing- ping message that is source of pong (body copied to pong message)
- Returns:
- WebSocketMessage
 
 - 
createMessageClosepublic static WebSocketMessage createMessageClose(boolean mask, int reasonCode, String reasonStr) Create a close message- Parameters:
- mask- true, to mask message
- reasonCode- reason code, see IWebSocketSession.CLOSECODE_*
- reasonStr- reason string, see IWebSocketSession.CLOSESTR_*
- Returns:
- WebSocketMessage
 
 - 
createMessageTextpublic static WebSocketMessage createMessageText(boolean mask, String messageStr) Create text message- Parameters:
- mask- true, to mask message
- messageStr- string data
- Returns:
- WebSocketMessage
 
 - 
createMessageBinarypublic static WebSocketMessage createMessageBinary(boolean mask, byte[] buffer, int offset, int len) Create binary message- Parameters:
- mask- true, to mask message
- buffer- body buffer
- offset- offset into body buffer
- len- len of message
- Returns:
- WebSocketMessage
 
 - 
createMessageBinarypublic static WebSocketMessage createMessageBinary(boolean mask, com.wowza.util.IFasterByteArrayOutputStream buffer, int offset, int len) Create binary message- Parameters:
- mask- true, to mask message
- buffer- body buffer
- offset- offset into body buffer
- len- len of message
- Returns:
- WebSocketMessage
 
 - 
createMessageBinarypublic static WebSocketMessage createMessageBinary(boolean mask, byte[] buffer) Create binary message- Parameters:
- mask- true, to mask message
- buffer- body buffer
- Returns:
- WebSocketMessage
 
 - 
isControlMessagepublic boolean isControlMessage() Is message a control message- Returns:
- true if control message (ping, ping, close...)
 
 - 
addBufferpublic void addBuffer(byte[] buffer, int offset, int len, boolean fragmented)Used internally to add read TCP bytes into current pending message- Parameters:
- buffer- buffer
- offset- offset
- len- len
- fragmented- true, if fragmented
 
 - 
getTypepublic int getType() Get message type, see OPCODE_*- Returns:
- message type
 
 - 
isTextpublic boolean isText() Is message text message- Returns:
- true if text message
 
 - 
isBinarypublic boolean isBinary() Is binary message- Returns:
- true if binary message
 
 - 
getCloseReasonpublic int getCloseReason() If close message, get the close reason- Returns:
- close reason (-1 if not close message or no reason)
 
 - 
getCloseReasonStrpublic String getCloseReasonStr() If close message, get the close reason str- Returns:
- close reason str (null if not close message or no reason)
 
 - 
getValueStringpublic String getValueString() If text message, get body as string- Returns:
- get body as string
 
 - 
getBufferpublic byte[] getBuffer() Get the raw binary message data (also need offset and len)- Returns:
- raw binary message data
 
 - 
getOffsetpublic int getOffset() Get offset into message buffer- Returns:
- offset into message buffer
 
 - 
getLenpublic int getLen() Get len of message buffer data- Returns:
- len of message buffer data
 
 - 
setTypepublic void setType(int type) Set message type, see OPCODE_*- Parameters:
- type- message type
 
 - 
sendMessagepublic long sendMessage(com.wowza.util.IFasterByteArrayWriteReference out) Internal method to send message over TCP connection- Parameters:
- out- writer
- Returns:
- number of bytes written
 
 - 
toStringpublic String toString() Get message as a string (use getValueString() to get the body value of text messages)- Overrides:
- toStringin class- Object
 
 
- 
 
-