1
0
mirror of https://gitlab.com/comunic/comunicmobile synced 2024-11-22 21:09:21 +00:00

Close WebSocket on logout

This commit is contained in:
Pierre HUBERT 2020-04-20 08:47:08 +02:00
parent cb47f0351e
commit 40cf1b1ddc
2 changed files with 9 additions and 0 deletions

View File

@ -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

View File

@ -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