setEventHandler method Null safety

void setEventHandler(
  1. RtcChannelEventHandler handler

Sets the channel event handler.

After setting the channel event handler, you can listen for channel events and receive the statistics of the corresponding RtcChannel instance.

Parameter handler The event handler.


void setEventHandler(RtcChannelEventHandler handler) {
  _handler = handler;
  _subscription ??= _stream.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);