rename _manuallyClosed to _manuallyDisconnected

This commit is contained in:
Salvatore Giordano
2021-01-26 10:51:26 +01:00
parent 20f37a6ff0
commit 388829e32d
@@ -108,7 +108,9 @@ class WebSocket {
WebSocketChannel _channel;
Timer _healthCheck, _reconnectionMonitor;
DateTime _lastEventAt;
bool _manuallyClosed = false, _connecting = false, _reconnecting = false;
bool _manuallyDisconnected = false,
_connecting = false,
_reconnecting = false;
Event _decodeEvent(String source) {
return Event.fromJson(json.decode(source));
@@ -118,7 +120,7 @@ class WebSocket {
/// Connect the WS using the parameters passed in the constructor
Future<Event> connect() {
_manuallyClosed = false;
_manuallyDisconnected = false;
if (_connecting) {
logger.severe('already connecting');
@@ -151,7 +153,7 @@ class WebSocket {
void _onDone() {
_connecting = false;
if (_manuallyClosed) {
if (_manuallyDisconnected) {
return;
}
@@ -290,14 +292,14 @@ class WebSocket {
/// Disconnects the WS and releases eventual resources
Future<void> disconnect() async {
if (_manuallyClosed) {
if (_manuallyDisconnected) {
return;
}
logger.info('disconnecting');
_connectionCompleter = Completer();
_cancelTimers();
_reconnecting = false;
_manuallyClosed = true;
_manuallyDisconnected = true;
connectionStatus.value = ConnectionStatus.disconnected;
connectionStatus.dispose();
return _channel.sink.close();