connect method
Start opening websocket connection
Implementation
Future connect() async {
_loggerService.log('Connecting to ' + Tools.makeBaseURL(_options));
if (isConnected) {
_loggerService.warn('Reconnecting...');
}
_connecting = true;
_ws = await WebSocket.connect(Tools.makeBaseURL(_options))
.timeout(Duration(milliseconds: 5000));
_connecting = false;
_loggerService.log('Connected.');
_channel = IOWebSocketChannel(_ws!);
onOpen.add('Opened');
_channel?.stream.listen((message) {
onMessage.add(message);
});
}