Browse Source

feat(rtc): 添加-发送消息功能 实现 sendMessage 方法用于发送字符串消息

- 使用 UTF-8 编码将消息转换为字节流
- 调用引擎的 sendStreamMessage 接口发送数据
- 打印发送成功的日志信息- 支持通过 streamId 发送消息到指定流
ios
Jolie 4 months ago
parent
commit
fc4efc6edf
1 changed files with 11 additions and 0 deletions
  1. 11
      lib/rtc/rtc_manager.dart

11
lib/rtc/rtc_manager.dart

@ -421,6 +421,17 @@ class RTCManager {
print('客户端角色已设置为:$role');
}
///
Future<void> sendMessage(String message) async {
Uint8List data = utf8.encode(message);
await _engine!.sendStreamMessage(
streamId: _streamId ?? 0,
data: data,
length: data.length,
);
print('已发送消息:$message');
}
/// ID
String? get currentChannelId => _currentChannelId;

Loading…
Cancel
Save