connect method
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:
- VIClientError.ERROR_CONNECTION_FAILED - If the connection is currently establishing or already established, or an error occurred.
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;
}
}