fm.liveswitch.DataChannelReceiveArgs Class Reference

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

Public Member Functions

 DataChannelReceiveArgs ()
 
fm.liveswitch.DataBuffer getDataBytes ()
 Gets a received data buffer if it is available. More...
 
String getDataString ()
 Gets a received data string if it is available. More...
 
fm.liveswitch.ConnectionInfo getRemoteConnectionInfo ()
 Gets the remote connection info. More...
 
void setDataBytes (fm.liveswitch.DataBuffer value)
 Sets a received data buffer if it is available. More...
 
void setDataString (String value)
 Sets a received data string if it is available. More...
 

Detailed Description

Arguments for the data channel receive event.

Constructor & Destructor Documentation

◆ DataChannelReceiveArgs()

fm.liveswitch.DataChannelReceiveArgs.DataChannelReceiveArgs ( )

Member Function Documentation

◆ getDataBytes()

fm.liveswitch.DataBuffer fm.liveswitch.DataChannelReceiveArgs.getDataBytes ( )

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#getLength bytes starting with the fm.liveswitch.DataBuffer#getIndex byte should be read. See examples.

Example:

channel.setOnReceive(messageArgs -> {
DataBuffer dataBytes = messageArgs.getDataBytes();
if (dataBytes != null) {
byte[] bytes = dataBytes.getData(); // The payload byte[] might contain extra bytes that are not part of the payload.
int index = dataBytes.getIndex(); // Starting index of the payload’s bytes you want.
int length = dataBytes.getLength(); // Length of the payload’s bytes you want.
byte firstByte = dataBytes.getData()[index]; // An example of acccessing the first byte.
}
});

◆ getDataString()

String fm.liveswitch.DataChannelReceiveArgs.getDataString ( )

Gets a received data string if it is available.

Set to null if a data string was not received.

Example:

channel.addOnReceive(new IAction1<DataChannelArgs>() {
@Override
public void invoke(DataChannelArgs args) {
String dataString = messageArgs.getDataString();
if(dataString != null) {
//Do something with the string.
}
}
});

◆ getRemoteConnectionInfo()

fm.liveswitch.ConnectionInfo fm.liveswitch.DataChannelReceiveArgs.getRemoteConnectionInfo ( )

Gets the remote connection info.

◆ setDataBytes()

void fm.liveswitch.DataChannelReceiveArgs.setDataBytes ( fm.liveswitch.DataBuffer  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 fm.liveswitch.DataBuffer, only fm.liveswitch.DataBuffer#getLength bytes starting with the fm.liveswitch.DataBuffer#getIndex byte should be read. See examples.

Example:

channel.setOnReceive(messageArgs -> {
DataBuffer dataBytes = messageArgs.getDataBytes();
if (dataBytes != null) {
byte[] bytes = dataBytes.getData(); // The payload byte[] might contain extra bytes that are not part of the payload.
int index = dataBytes.getIndex(); // Starting index of the payload’s bytes you want.
int length = dataBytes.getLength(); // Length of the payload’s bytes you want.
byte firstByte = dataBytes.getData()[index]; // An example of acccessing the first byte.
}
});

◆ setDataString()

void fm.liveswitch.DataChannelReceiveArgs.setDataString ( String  value)

Sets a received data string if it is available.

Set to null if a data string was not received.

Example:

channel.addOnReceive(new IAction1<DataChannelArgs>() {
@Override
public void invoke(DataChannelArgs args) {
String dataString = messageArgs.getDataString();
if(dataString != null) {
//Do something with the string.
}
}
});