startSDK method

void startSDK({
  1. required String appId,
  2. required String token,
  3. required dynamic callEvent(
    1. CallEvent eventName,
    2. Map<String, dynamic>? data
    ),
  4. dynamic completion(
    1. int
    )?,
})

Implementation

void startSDK({
  required String appId,
  required String token,
  required Function(CallEvent eventName, Map<String,
      dynamic>? data) callEvent,
  Function(int)? completion}) async {
  Log().info("startSDK, appId = $appId, token = $token");
  CallManager().authenticateSDK(
      appId: appId, token: token, completion: completion);
  _eventSubscription = CallManager().onDelegateEvent.listen((event) {
    final eventName = BaseEntity.stringValue(event, "name");
    if (eventName == kNotiWebRtcConfOnConnecting) {
      callEvent(CallEvent.connecting, null);
    } else if (eventName == kNotiWebRtcConfOnConnected) {
      callEvent(CallEvent.connected, null);
    } else if (eventName == kNotiWebRtcConfOnEnded) {
      callEvent(CallEvent.ended, null);
    } else if (eventName == kNotiWebRtcConfOnAudioRouteChanged) {
      callEvent(CallEvent.audio, null);
    } else if (eventName == kNotiWebRtcConfOnReceiveCall) {
      final data = BaseEntity.mapValue(event, "info");
      callEvent(CallEvent.notify, data);
    } else if (eventName == kNotiWebRtcConfOnBusyCall) {
      final data = BaseEntity.mapValue(event, "info");
      callEvent(CallEvent.busy, data);
    } else if (eventName == kNotiWebRtcConfOnAddVideo) {
      final data = BaseEntity.mapValue(event, "info");
      callEvent(CallEvent.videoAdded, data);
    } else if (eventName == kNotiWebRtcConfOnRemoveVideo) {
      final data = BaseEntity.mapValue(event, "info");
      callEvent(CallEvent.videoRemoved, data);
    }
  });

  Log().info("startSDK, _eventSubscription = $_eventSubscription");
}