connect method

Future<void> connect({
  1. required VINode node,
  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).

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({
  required VINode node,
  bool connectivityCheck = false,
  List<String>? servers,
}) async {
  _changeClientState(VIClientState.Connecting);
  try {
    await _channel.invokeMethod<void>('Client.connect', <String, dynamic>{
      'connectivityCheck': connectivityCheck,
      'servers': servers,
      'node': node.name,
    });
    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;
  }
}