🐛 Fix listen stream that already listened
This commit is contained in:
		| @@ -36,6 +36,8 @@ class AccountProvider extends GetxController { | ||||
|   } | ||||
|  | ||||
|   void connect({noRetry = false}) async { | ||||
|     if (isConnected.value) return; | ||||
|  | ||||
|     final AuthProvider auth = Get.find(); | ||||
|     if (!await auth.isAuthorized) throw Exception('unauthorized'); | ||||
|  | ||||
| @@ -66,6 +68,7 @@ class AccountProvider extends GetxController { | ||||
|  | ||||
|   void disconnect() { | ||||
|     websocket?.sink.close(WebSocketStatus.normalClosure); | ||||
|     websocket = null; | ||||
|     isConnected.value = false; | ||||
|   } | ||||
|  | ||||
|   | ||||
| @@ -17,6 +17,8 @@ class ChatProvider extends GetxController { | ||||
|   StreamController<NetworkPackage> stream = StreamController.broadcast(); | ||||
|  | ||||
|   void connect({noRetry = false}) async { | ||||
|     if (isConnected.value) return; | ||||
|  | ||||
|     final AuthProvider auth = Get.find(); | ||||
|     if (!await auth.isAuthorized) throw Exception('unauthorized'); | ||||
|  | ||||
| @@ -47,6 +49,7 @@ class ChatProvider extends GetxController { | ||||
|  | ||||
|   void disconnect() { | ||||
|     websocket?.sink.close(WebSocketStatus.normalClosure); | ||||
|     websocket = null; | ||||
|     isConnected.value = false; | ||||
|   } | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user