sendUserMessage method
Future<int?>
sendUserMessage({
- required string userId,
- required string messageStr,
- required MessageConfig config,
@detail api @brief 给房间内指定的用户发送点对点文本消息(P2P)。 @param userId 消息接收用户的 ID @param messageStr 发送的文本消息内容。消息不超过 64 KB。 @param config 消息发送的可靠/有序类型,参看 MessageConfig{@link #MessageConfig} @return - >0:发送成功,返回这次发送消息的编号,从 1 开始递增 - -1:发送失败,RTCRoom 实例未创建 - -2:发送失败,uid 为空 @note - 在发送房间内文本消息前,必须先调用 joinRTSRoom{@link #RTSRoom#joinRTSRoom} 加入房间。 - 调用后,会收到 onUserMessageSendResult{@link #IRTSRoomEventHandler#onUserMessageSendResult} 回调,通知消息发送成功或失败; - 若消息发送成功,则 userId 所指定的用户会收到 onUserMessageReceived{@link #IRTSRoomEventHandler#onUserMessageReceived} 回调。
Implementation
Future<int?> sendUserMessage(
{required string userId,
required string messageStr,
required MessageConfig config}) async {
$a() => ($instance as $p_a.RTCRoom).sendUserMessage(
userId, messageStr, t_MessageConfig.code_to_android(config));
$i() => ($instance as $p_i.ByteRTCRoom).sendUserMessage(
userId, messageStr, t_MessageConfig.code_to_ios(config));
if (Platform.isAndroid) {
return $a();
} else if (Platform.isIOS) {
return $i();
} else {
throw UnsupportedError(
'Not Support Platform ${Platform.operatingSystem}');
}
}