connect method
returns true if the connection was successful
Implementation
Future<bool> connect({required ConnectionSource connectionSource}) async {
if (_channel != null) {
Logger.log.w("Relay already connected");
return Future.value(true);
}
this.connectionSource = connectionSource;
tryingToConnect();
_channel = WebSocketChannel.connect(Uri.parse(url));
// ready check
bool r = await isReady();
if (!r) {
Logger.log.w("Relay not ready");
failedToConnect();
return false;
}
_listen();
Logger.log.d("🔗 Relay connected: $url");
succeededToConnect();
return true;
}