connect method
Throws SessionConnectException
if the connection fails.
Implementation
@override
Future<void> connect() async {
debugPrint('Session.connect: $token');
final completer = Completer<void>();
_jsVideoSession.connect(
token,
JSErrorCallback((error) {
if (error != null) {
final exception = SessionConnectExceptionFactory.fromJsError(error);
debugPrint('Session.connect.callback.error: $exception');
completer.completeError(exception);
} else {
debugPrint('Session.connect.success');
completer.complete();
}
}),
);
return completer.future.catchError((e) {
debugPrint('Session.connect.error: $e');
throw e;
}).timeout(
const Duration(seconds: 30),
onTimeout: () async {
debugPrint('Session.connect.timeout');
throw SessionConnectTimeoutException();
},
);
}