mirror of
https://gitlab.com/comunic/comunicmobile
synced 2024-11-26 06:49:22 +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/api_helper.dart';
|
||||||
import 'package:comunic/helpers/preferences_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/api_request.dart';
|
||||||
import 'package:comunic/models/authentication_details.dart';
|
import 'package:comunic/models/authentication_details.dart';
|
||||||
import 'package:comunic/models/login_tokens.dart';
|
import 'package:comunic/models/login_tokens.dart';
|
||||||
@ -82,6 +83,9 @@ class AccountHelper {
|
|||||||
Future<void> signOut() async {
|
Future<void> signOut() async {
|
||||||
await (await PreferencesHelper.getInstance()).setLoginTokens(null);
|
await (await PreferencesHelper.getInstance()).setLoginTokens(null);
|
||||||
_currentUserID = 0;
|
_currentUserID = 0;
|
||||||
|
|
||||||
|
// Close current web socket
|
||||||
|
WebSocketHelper.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Create a new user account
|
/// 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
|
/// Send a new message
|
||||||
///
|
///
|
||||||
/// This method might throw an [Exception] in case of failure
|
/// This method might throw an [Exception] in case of failure
|
||||||
|
Loading…
Reference in New Issue
Block a user