Merge pull request #236 from GetStream/hotfix/wsDisconnect
Hotfix/ws disconnect
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
#!/bin/bash
|
||||
|
||||
flutter pub global activate melos 0.4.0-dev.2
|
||||
flutter pub global activate melos 0.4.0+1
|
||||
echo "::add-path::$HOME/.pub-cache/bin"
|
||||
echo "::add-path::$GITHUB_WORKSPACE/_flutter/.pub-cache/bin"
|
||||
echo "::add-path::$GITHUB_WORKSPACE/_flutter/bin/cache/dart-sdk/bin"
|
||||
@@ -1,3 +1,7 @@
|
||||
## 0.2.24+1
|
||||
|
||||
- Stop ws reconnection after calling disconnect
|
||||
|
||||
## 0.2.24
|
||||
|
||||
- Create enum for push providers
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -289,11 +291,15 @@ class WebSocket {
|
||||
}
|
||||
|
||||
/// Disconnects the WS and releases eventual resources
|
||||
Future<void> disconnect() {
|
||||
Future<void> disconnect() async {
|
||||
if (_manuallyDisconnected) {
|
||||
return;
|
||||
}
|
||||
logger.info('disconnecting');
|
||||
_connectionCompleter = Completer();
|
||||
_cancelTimers();
|
||||
_manuallyClosed = true;
|
||||
_reconnecting = false;
|
||||
_manuallyDisconnected = true;
|
||||
connectionStatus.value = ConnectionStatus.disconnected;
|
||||
connectionStatus.dispose();
|
||||
return _channel.sink.close();
|
||||
|
||||
@@ -2,4 +2,4 @@ import 'package:stream_chat/src/client.dart';
|
||||
|
||||
/// Current package version
|
||||
/// Used in [Client] to build the `x-stream-client` header
|
||||
const PACKAGE_VERSION = '0.2.24';
|
||||
const PACKAGE_VERSION = '0.2.24+1';
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
name: stream_chat
|
||||
homepage: https://getstream.io/
|
||||
description: The official Dart client for Stream Chat, a service for building chat applications.
|
||||
version: 0.2.24
|
||||
version: 0.2.24+1
|
||||
repository: https://github.com/GetStream/stream-chat-dart
|
||||
issue_tracker: https://github.com/GetStream/stream-chat-dart/issues
|
||||
|
||||
|
||||
Reference in New Issue
Block a user