/ fm / liveswitch / DataChannelReceiveArgs
Class: DataChannelReceiveArgs
fm.liveswitch.DataChannelReceiveArgs
Arguments for the data channel receive event.
Table of contents
Constructors
Methods
Constructors
constructor
+ new DataChannelReceiveArgs(): DataChannelReceiveArgs
Returns: DataChannelReceiveArgs
Defined in: Generated/TypeScript/fm.liveswitch/DataChannelReceiveArgs.ts:19
Methods
getDataBytes
▸ getDataBytes(): DataBuffer
Gets a received data buffer if it is available. Set to null if a data string was not received. Bear in mind that when accessing the payload data from the [[fm.liveswitch.dataBuffer]], only [[fm.liveswitch.dataBuffer.length]] bytes starting with the [[fm.liveswitch.dataBuffer.index]] byte should be read. See examples.
TypeScript Example:
channel.setOnReceive((messageArgs) => {
let dataBytes = messageArgs.getDataBytes();
if (dataBytes != null) {
var bytes = dataBytes.getData(); // The payload byte[] might contain extra bytes that are not part of the payload.
var index = dataBytes.getIndex(); // Starting index of the payload’s bytes you want.
var length = dataBytes.getLength(); // Length of the payload’s bytes you want.
var firstByte = dataBytes.getData()[index]; // An example of acccessing the first byte.
}
});
Returns: DataBuffer
Defined in: Generated/TypeScript/fm.liveswitch/DataChannelReceiveArgs.ts:52
getDataString
▸ getDataString(): string
Gets a received data string if it is available. Set to null if a data string was not received.
TypeScript Example:
channel.addOnReceive((msg) => {
let str = msg.getDataString()
if(str != null) {
//Do something with the string.
}
};
Returns: string
Defined in: Generated/TypeScript/fm.liveswitch/DataChannelReceiveArgs.ts:83
getRemoteConnectionInfo
▸ getRemoteConnectionInfo(): ConnectionInfo
Gets the remote connection info.
Returns: ConnectionInfo
Defined in: Generated/TypeScript/fm.liveswitch/DataChannelReceiveArgs.ts:95
getTypeString
▸ getTypeString(): string
Returns: string
Defined in: Generated/TypeScript/fm.liveswitch/DataChannelReceiveArgs.ts:9
setDataBytes
▸ setDataBytes(value
: DataBuffer): void
Sets a received data buffer if it is available. Set to null if a data string was not received. Bear in mind that when accessing the payload data from the [[fm.liveswitch.dataBuffer]], only [[fm.liveswitch.dataBuffer.length]] bytes starting with the [[fm.liveswitch.dataBuffer.index]] byte should be read. See examples.
TypeScript Example:
channel.setOnReceive((messageArgs) => {
let dataBytes = messageArgs.getDataBytes();
if (dataBytes != null) {
var bytes = dataBytes.getData(); // The payload byte[] might contain extra bytes that are not part of the payload.
var index = dataBytes.getIndex(); // Starting index of the payload’s bytes you want.
var length = dataBytes.getLength(); // Length of the payload’s bytes you want.
var firstByte = dataBytes.getData()[index]; // An example of acccessing the first byte.
}
});
Parameters:
Name | Type |
---|---|
value |
DataBuffer |
Returns: void
Defined in: Generated/TypeScript/fm.liveswitch/DataChannelReceiveArgs.ts:122
setDataString
▸ setDataString(value
: string): void
Sets a received data string if it is available. Set to null if a data string was not received.
TypeScript Example:
channel.addOnReceive((msg) => {
let str = msg.getDataString()
if(str != null) {
//Do something with the string.
}
};
Parameters:
Name | Type |
---|---|
value |
string |
Returns: void
Defined in: Generated/TypeScript/fm.liveswitch/DataChannelReceiveArgs.ts:153