wsConnect method
Implementation
@override
Future<bool> wsConnect() async {
logger("wsConnect", level: Level.debug);
try {
final uri = Uri.parse(getIt.get<ConnectionService>().serverUrl);
await HttpClient().get(uri.host, uri.port, uri.path);
_channel = WebSocketChannel.connect(uri);
return true;
}catch (error) {
if (!error.toString().contains("SocketException: Connection")) {
logger(error.toString(), level: Level.error);
_channel = WebSocketChannel.connect(Uri.parse(getIt.get<ConnectionService>().serverUrl));
return true;
} else {
logger("Server is not online or App is disconnected from the internet", level: Level.debug);
return false;
}
}
}