void setEventHandler (
RtcChannelEventHandler handler
)
设置频道事件句柄。
设置后,你可以通过 RtcChannel 回调监听对应频道内的事件、获取频道数据。
Parameter handler
事件句柄。
Implementation
void setEventHandler(RtcChannelEventHandler handler) {
_handler = handler;
_subscription ??= _eventChannel.receiveBroadcastStream().listen((event) {
final eventMap = Map<dynamic, dynamic>.from(event);
final channelId = eventMap['channelId'];
final methodName = eventMap['methodName'] as String;
final data = List<dynamic>.from(eventMap['data']);
_channels[channelId]?._handler?.process(methodName, data);
});
}