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