sendCustomCmdMsg abstract method
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:
- 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
andordered
must be set to the same value (true
orfalse
) and cannot be set to different values currently.- We strongly recommend you set different
cmdID
values for messages of different types. This can reduce message delay when orderly sending is required. - 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);