authenticateSDK method

void authenticateSDK({
  1. required String appId,
  2. required String token,
  3. dynamic completion(
    1. int result
    )?,
})

Implementation

void authenticateSDK({required String appId,
    required String token, Function(int result)? completion}) async {

  Log().info("authenticateSDK");
  final verifyResult = await NetworkManager().verifyClientToken(appId: appId, clientToken: token);
  Log().info('verifyClientToken result = $verifyResult');
  final serverDomain = BaseEntity.stringValue(verifyResult, "domain");
  final clientId = BaseEntity.stringValue(verifyResult, "clientId") ?? "clientTest";
  if (serverDomain != null && serverDomain.isNotEmpty) {
    _serverDomain = serverDomain;
    final socketUrl = sprintf(SIGNAL_CONTROLLER_URL, [serverDomain, appId, clientId]);
    final deviceId = await _getDeviceId();
    _currentCallMetaInfo = {"appId": appId, "socketUrl":socketUrl, "token":token, "deviceId": deviceId};
    _autoConnect = true;
    _establishSocketConnection();
    _socketConnectionCallback = completion;
    _observeNetworkConnectionStatus();
    final webrtcResult = await _startWebRTC();
    Log().info('startWebRTC result = $webrtcResult');
    if (webrtcResult == false) {
      completion?.call(-1);
      _socketConnectionCallback = null;
    }
  } else {
    completion?.call(-1);
  }
}