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