From 459757b2925c97015c4113c750b12323ca5adf5d Mon Sep 17 00:00:00 2001 From: Pierre HUBERT Date: Thu, 18 Feb 2021 19:36:51 +0100 Subject: [PATCH] Fix issues with WebSocket --- lib/helpers/websocket_helper.dart | 1 + lib/ui/widgets/init_widget.dart | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/helpers/websocket_helper.dart b/lib/helpers/websocket_helper.dart index 68305cf..1281928 100644 --- a/lib/helpers/websocket_helper.dart +++ b/lib/helpers/websocket_helper.dart @@ -67,6 +67,7 @@ class WebSocketHelper { // Clear Futures queue _requests.clear(); + _ws = null; EventsHelper.emit(WSClosedEvent()); }, ); diff --git a/lib/ui/widgets/init_widget.dart b/lib/ui/widgets/init_widget.dart index 54ae38a..c83f5b0 100644 --- a/lib/ui/widgets/init_widget.dart +++ b/lib/ui/widgets/init_widget.dart @@ -57,6 +57,8 @@ class _InitializeWidgetState extends SafeState { /// Try to connect to server void _tryConnect() async { try { + print("Attempting WebSocket connection..."); + setState(() { _error = false; }); @@ -78,7 +80,7 @@ class _InitializeWidgetState extends SafeState { @override Widget build(BuildContext context) { - return !_error && WebSocketHelper.isConnected() + return (!_error && WebSocketHelper.isConnected()) ? (isTablet(context) ? TabletRoute(key: mainControllerKey) : SmartphoneMainRoute(key: mainControllerKey))