public class ChannelData extends Object
Modifier and Type | Field and Description |
---|---|
private char |
channelNumber
The channel number.
|
private byte[] |
data
The data.
|
static char |
HEADER_LENGTH
Size of the header.
|
Constructor and Description |
---|
ChannelData()
Constructor.
|
Modifier and Type | Method and Description |
---|---|
static ChannelData |
decode(byte[] binMessage,
char offset)
Constructs a message from its binary representation.
|
static ChannelData |
decode(byte[] binMessage,
char offset,
char arrayLen)
Deprecated.
|
byte[] |
encode()
Deprecated.
|
byte[] |
encode(boolean pad)
Returns a binary representation of this message.
|
char |
getChannelNumber()
Get the channel number.
|
byte[] |
getData()
Get the data.
|
char |
getDataLength()
Get the data length (without padding).
|
static boolean |
isChannelDataMessage(byte[] binMessage)
Checks if the given binary message is a ChannelData Message.
|
private static int |
padTo4(int num) |
void |
setChannelNumber(char channelNumber)
Set the channel number
|
void |
setData(byte[] data)
Set the data.
|
private static boolean |
validateChannelNumber(char channelNumber)
Determines whether a specific channel number is in the valid channel
number range defined by the TURN RFC.
|
private char channelNumber
private byte[] data
public static char HEADER_LENGTH
public void setChannelNumber(char channelNumber)
channelNumber
- the channel numberpublic char getChannelNumber()
public void setData(byte[] data)
data
- the datapublic byte[] getData()
public char getDataLength()
private static int padTo4(int num)
private static boolean validateChannelNumber(char channelNumber)
channelNumber
- the channel number to be checked for being in the
valid channel number range defined by the TURN RFCpublic byte[] encode() throws StunException
StunException
- if the channel number is invalidpublic byte[] encode(boolean pad) throws StunException
pad
- determine if we pad this messageStunException
- if the channel number is invalidpublic static ChannelData decode(byte[] binMessage, char offset, char arrayLen) throws StunException
binMessage
- the binary array that contains the encoded messageoffset
- the index where the message starts.arrayLen
- the length of the messageStunException
- ILLEGAL_ARGUMENT if one or more of the arguments
have invalid values.public static ChannelData decode(byte[] binMessage, char offset) throws StunException
binMessage
- the binary array that contains the encoded messageoffset
- the index where the message starts.StunException
- ILLEGAL_ARGUMENT if one or more of the arguments
have invalid values.public static boolean isChannelDataMessage(byte[] binMessage)
binMessage
- binary message to check.Copyright © 2018. All rights reserved.