FMLiveSwitchDataChannelReceiveArgs Class Reference

Arguments for the data channel receive event. More...

Instance Methods

(FMLiveSwitchDataBuffer *) - dataBytes
 Gets a received data buffer if it is available. More...
 
(NSString *) - dataString
 Gets a received data string if it is available. More...
 
(instancetype) - init
 
(FMLiveSwitchConnectionInfo *) - remoteConnectionInfo
 Gets the remote connection info. More...
 
(void) - setDataBytes:
 Sets a received data buffer if it is available. More...
 
(void) - setDataString:
 Sets a received data string if it is available. More...
 

Class Methods

(FMLiveSwitchDataChannelReceiveArgs *) + dataChannelReceiveArgs
 

Detailed Description

Arguments for the data channel receive event.

Method Documentation

◆ dataBytes

- (FMLiveSwitchDataBuffer*) dataBytes

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 FMLiveSwitchDataBuffer, only length (FMLiveSwitchDataBuffer) bytes starting with the index (FMLiveSwitchDataBuffer) byte should be read. See examples.

Example:

channel.setOnReceive { [weak self] (messageArgs: Any!) in
let dataBytes = (messageArgs as! FMLiveSwitchDataChannelReceiveArgs).dataBytes()
if (dataBytes != nil) {
let bytes = dataBytes!.data() // The payload byte[] might contain extra bytes that are not part of the payload.
let index = dataBytes!.index() // Starting index of the payload’s bytes you want.
let length = dataBytes!.length() // Length of the payload’s bytes you want.
let firstByte = dataBytes!.data()[Int(index)] // An example of acccessing the first byte.
}
}

◆ dataChannelReceiveArgs

+ (FMLiveSwitchDataChannelReceiveArgs*) dataChannelReceiveArgs

◆ dataString

- (NSString*) dataString

Gets a received data string if it is available.

Set to null if a data string was not received.

Example:

channel.setOnReceive{ [weak self] (msg: Any!) in
let message = msg as! FMLiveSwitchDataChannelReceiveArgs
let messageStr = message.dataString()
if (messageStr != nil){
//Do something with the string.
}
}

◆ init

- (instancetype) init

◆ remoteConnectionInfo

- (FMLiveSwitchConnectionInfo*) remoteConnectionInfo

Gets the remote connection info.

◆ setDataBytes:

- (void) setDataBytes: (FMLiveSwitchDataBuffer *)  value

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 FMLiveSwitchDataBuffer, only length (FMLiveSwitchDataBuffer) bytes starting with the index (FMLiveSwitchDataBuffer) byte should be read. See examples.

Example:

channel.setOnReceive { [weak self] (messageArgs: Any!) in
let dataBytes = (messageArgs as! FMLiveSwitchDataChannelReceiveArgs).dataBytes()
if (dataBytes != nil) {
let bytes = dataBytes!.data() // The payload byte[] might contain extra bytes that are not part of the payload.
let index = dataBytes!.index() // Starting index of the payload’s bytes you want.
let length = dataBytes!.length() // Length of the payload’s bytes you want.
let firstByte = dataBytes!.data()[Int(index)] // An example of acccessing the first byte.
}
}

◆ setDataString:

- (void) setDataString: (NSString *)  value

Sets a received data string if it is available.

Set to null if a data string was not received.

Example:

channel.setOnReceive{ [weak self] (msg: Any!) in
let message = msg as! FMLiveSwitchDataChannelReceiveArgs
let messageStr = message.dataString()
if (messageStr != nil){
//Do something with the string.
}
}