connect method

Future<void> connect({
  1. VINode? node = null,
  2. bool connectivityCheck = false,
  3. List<String>? servers,
})

Connects to the Voximplant Cloud.

Checks whether UDP traffic will flow correctly between device and the Voximplant Cloud if connectivityCheck is enabled (disabled by default).

Optional node - Specifies the node the Voximplant account belongs to.

Optional connectivityCheck - Checks whether UDP traffic will flow correctly between device and Voximplant cloud. This check reduces connection speed.

Optional servers - List of server names of particular media gateways for connection.

Throws VIException if the connection to the Voximplant Cloud could not be established.

Errors:

Implementation

Future<void> connect({
  VINode? node = null,
  bool connectivityCheck = false,
  List<String>? servers,
}) async {
  _changeClientState(VIClientState.Connecting);
  try {
    if (node != null) {
      await _channel.invokeMethod<void>('Client.connect', <String, dynamic>{
        'connectivityCheck': connectivityCheck,
        'servers': servers,
        'node': node.name,
      });
    } else {
      await _channel.invokeMethod<void>('Client.connect', <String, dynamic>{
        'connectivityCheck': connectivityCheck,
        'servers': servers,
      });
    }
    VIClientState state = await getClientState();
    _changeClientState(state);
  } on PlatformException catch (e) {
    VIClientState state = await getClientState();
    _changeClientState(state);
    throw VIException(e.code, e.message);
  } catch (e) {
    _VILog._e('VIClient.connect: catch: $e');
    VIClientState state = await getClientState();
    _changeClientState(state);
    rethrow;
  }
}