mirror of
https://gitlab.com/comunic/comunicmobile
synced 2024-11-22 12:59:21 +00:00
Close WebSocket on logout
This commit is contained in:
parent
cb47f0351e
commit
40cf1b1ddc
@ -1,5 +1,6 @@
|
||||
import 'package:comunic/helpers/api_helper.dart';
|
||||
import 'package:comunic/helpers/preferences_helper.dart';
|
||||
import 'package:comunic/helpers/websocket_helper.dart';
|
||||
import 'package:comunic/models/api_request.dart';
|
||||
import 'package:comunic/models/authentication_details.dart';
|
||||
import 'package:comunic/models/login_tokens.dart';
|
||||
@ -82,6 +83,9 @@ class AccountHelper {
|
||||
Future<void> signOut() async {
|
||||
await (await PreferencesHelper.getInstance()).setLoginTokens(null);
|
||||
_currentUserID = 0;
|
||||
|
||||
// Close current web socket
|
||||
WebSocketHelper.close();
|
||||
}
|
||||
|
||||
/// Create a new user account
|
||||
|
@ -72,6 +72,11 @@ class WebSocketHelper {
|
||||
);
|
||||
}
|
||||
|
||||
/// Close current WebSocket (if any)
|
||||
static close() {
|
||||
if (isConnected()) _ws.sink.close();
|
||||
}
|
||||
|
||||
/// Send a new message
|
||||
///
|
||||
/// This method might throw an [Exception] in case of failure
|
||||
|
Loading…
Reference in New Issue
Block a user