sendCustomCmdMsg method Null safety

Future<bool?> sendCustomCmdMsg(
  1. int cmdID,
  2. String data,
  3. bool reliable,
  4. bool ordered
)

Send custom message to all users in the room

This API can be used to broadcast your custom data to other users in the room though the audio/video data channel. Due to reuse of this channel, please strictly control the frequency of sending custom messages and message size; otherwise, the quality control logic of the audio/video data will be affected, causing uncertain issues.

Parameters:

cmdID Message ID. Value range: 1–10.

data Message to be sent, which can contain up to 1 KB (1,000 bytes) of data

reliable Whether reliable sending is enabled; if so, the recipient needs to temporarily store the data of a certain period to wait for re-sending, which will cause certain delay

ordered Whether orderly sending is enabled, i.e., whether the data should be received in the same order in which it is sent; if so, the recipient needs to temporarily store and sort messages, which will cause certain delay.

Returned value:

true: sent the message successfully; false: failed to send the message.

This API has the following restrictions:

  • Up to 30 messages can be sent per second to all users in the room (this is not supported for web and mini program currently).

  • A packet can contain up to 1 KB of data; if the threshold is exceeded, the packet is very likely to be discarded by the intermediate router or server.

  • A client can send up to 8 KB of data in total per second.

  • reliable and ordered must be set to the same value (true or false) and cannot be set to different values currently.

  • We strongly recommend you use different cmdID values for messages of different types. This can reduce message delay when orderly sending is required.

Implementation

Future<bool?> sendCustomCmdMsg(
    int cmdID, String data, bool reliable, bool ordered) {
  return _channel.invokeMethod('sendCustomCmdMsg', {
    "cmdID": cmdID,
    "data": data,
    "reliable": reliable,
    "ordered": ordered,
  });
}