sendCustomCmdMsg abstract method

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

Use UDP channel to send custom message to all users in room

This API allows you to use TRTC's UDP channel to broadcast custom data to other users in the current room for signaling transfer.

Other users in the room can receive the message through the TRTCCloudListener.onRecvCustomCmdMsg.

Parameters:

  • cmdID(int):
    • Message ID.
    • Value range: 1–10.
  • data(String):
    • Message to be sent. The maximum length of one single message is 1 KB.
  • ordered(bool):
    • Whether orderly sending is enabled, i.e., whether the data packets should be received in the same order in which they are sent; if so, a certain delay will be caused.
  • reliable(bool):
    • Whether reliable sending is enabled. Reliable sending can achieve a higher success rate but with a longer reception delay than unreliable sending.

Note:

  1. 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).
  2. 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.
  3. A client can send up to 8 KB of data in total per second.
  4. reliable and ordered must be set to the same value (true or false) and cannot be set to different values currently.
  5. We strongly recommend you set different cmdID values for messages of different types. This can reduce message delay when orderly sending is required.
  6. Currently only the anchor role is supported.

Return Description:

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

Implementation

bool sendCustomCmdMsg(int cmdID, String data, bool reliable, bool ordered);