Skip to content

Commit 8f5e7c4

Browse files
4.0.2
1 parent 2fa3479 commit 8f5e7c4

File tree

12 files changed

+156
-169
lines changed

12 files changed

+156
-169
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
## v4.0.2 (Jun 23, 2023)
2+
- Improved stability.
3+
14
## v4.0.1 (Jun 14, 2023)
25
- Improved stability.
36

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ Find out more about Sendbird Chat for Flutter on [the documentation](https://st.
2828
## Requirements
2929

3030
The minimum requirements for the Chat SDK for Flutter are:
31-
- Dart 2.17.0 or later
32-
- Flutter 2.11.0 or later
31+
- Dart 2.19.0 or later
32+
- Flutter 3.7.0 or later
3333

3434
> **Note**: Sendbird server supports Transport Layer Security (TLS) from version 1.0 up to 1.3. For example, in the server regions where TLS 1.3 isn’t available, lower versions, sequentially from 1.2 to 1.0, will be supported for secure data transmission.
3535
@@ -48,7 +48,7 @@ Before installing Sendbird Chat SDK, you need to create a Sendbird application o
4848

4949
```yaml
5050
dependencies:
51-
sendbird_chat_sdk: ^4.0.0
51+
sendbird_chat_sdk: ^4.0.2
5252
```
5353
5454
- Run `flutter pub get` command in your project directory.

analysis_options.yaml

Lines changed: 0 additions & 26 deletions
This file was deleted.

lib/src/internal/main/chat/chat.dart

Lines changed: 34 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ part 'chat_event_handler.dart';
4949
part 'chat_push.dart';
5050
part 'chat_user.dart';
5151

52-
const sdkVersion = '4.0.1';
52+
const sdkVersion = '4.0.2';
5353

5454
// Internal implementation for main class. Do not directly access this class.
5555
class Chat with WidgetsBindingObserver {
@@ -170,43 +170,39 @@ class Chat with WidgetsBindingObserver {
170170

171171
if (!isTest) {
172172
Connectivity().onConnectivityChanged.asBroadcastStream(
173-
onCancel: (controller) => {
174-
_connectivityResult = ConnectivityResult.none,
175-
controller.pause(),
176-
},
177-
onListen: (subscription) {
178-
subscription.onData((data) async {
179-
switch (data) {
180-
case ConnectivityResult.none:
181-
break;
182-
case ConnectivityResult.mobile:
183-
if (_connectivityResult == ConnectivityResult.none &&
184-
chatContext.sessionKey != null) {
185-
await connectionManager.reconnect(reset: true);
186-
}
187-
break;
188-
case ConnectivityResult.wifi:
189-
if (_connectivityResult == ConnectivityResult.none &&
190-
chatContext.sessionKey != null) {
191-
await connectionManager.reconnect(reset: true);
192-
}
193-
break;
194-
case ConnectivityResult.bluetooth:
195-
case ConnectivityResult.ethernet:
196-
if (_connectivityResult == ConnectivityResult.none &&
197-
chatContext.sessionKey != null) {
198-
await connectionManager.reconnect(reset: true);
199-
}
200-
break;
201-
case ConnectivityResult.vpn:
202-
break;
203-
default:
204-
break;
205-
}
206-
_connectivityResult = data;
207-
});
208-
},
209-
);
173+
onCancel: (controller) => {
174+
_connectivityResult = ConnectivityResult.none,
175+
controller.pause(),
176+
},
177+
onListen: (subscription) {
178+
subscription.onData((data) async {
179+
switch (data) {
180+
case ConnectivityResult.none:
181+
sbLog.d(StackTrace.current, 'ConnectivityResult.none');
182+
channelCache.markAsDirtyAll(); // Check
183+
break;
184+
case ConnectivityResult.mobile:
185+
case ConnectivityResult.wifi:
186+
case ConnectivityResult.ethernet:
187+
case ConnectivityResult.vpn:
188+
case ConnectivityResult.other:
189+
sbLog.d(
190+
StackTrace.current, '${data.toString()} => reconnect()');
191+
if (_connectivityResult == ConnectivityResult.none &&
192+
chatContext.sessionKey != null) {
193+
await connectionManager.reconnect(reset: true);
194+
}
195+
break;
196+
case ConnectivityResult.bluetooth:
197+
sbLog.d(StackTrace.current, 'ConnectivityResult.bluetooth');
198+
break;
199+
default:
200+
sbLog.d(StackTrace.current, data.toString());
201+
break;
202+
}
203+
_connectivityResult = data;
204+
});
205+
});
210206
}
211207
}
212208

lib/src/internal/main/chat_manager/command_manager.dart

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,10 @@ class CommandManager {
120120
}
121121

122122
Future<void> processCommand(Command cmd) async {
123-
sbLog.d(StackTrace.current,
124-
'\n-[cmd] ${cmd.cmd}\n-[payload] ${jsonEncoder.convert(cmd.payload)}');
123+
if (cmd.payload['cmd'] == null || cmd.payload['cmd'] != 'PONG') {
124+
sbLog.d(StackTrace.current,
125+
'\n-[cmd] ${cmd.cmd}\n-[payload] ${jsonEncoder.convert(cmd.payload)}');
126+
}
125127

126128
final unreadCountPayload = cmd.payload['unread_cnt'];
127129
if (unreadCountPayload != null) {
@@ -180,7 +182,9 @@ class CommandManager {
180182
} else if (cmd.isVote) {
181183
await _processVote(cmd);
182184
} else {
183-
sbLog.i(StackTrace.current, 'Pass command: ${cmd.cmd}');
185+
if (cmd.cmd != 'PONG') {
186+
sbLog.i(StackTrace.current, 'Pass command: ${cmd.cmd}');
187+
}
184188
}
185189
}
186190

lib/src/internal/main/logger/sendbird_logger.dart

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@ class SendbirdLogger {
1010
Logger logger;
1111

1212
static final _instance = SendbirdLogger._();
13-
SendbirdLogger._() : logger = Logger(level: Level.nothing);
13+
SendbirdLogger._() : logger = Logger(level: Level.nothing) {
14+
_setLogLevel(Level.nothing);
15+
}
1416
factory SendbirdLogger() => _instance;
1517

1618
void setLogLevel(LogLevel level) {

lib/src/internal/main/utils/async/async_queue.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ class AsyncQueue<T> {
5757
}
5858
} catch (e) {
5959
sbLog.e(StackTrace.current, 'e: $e');
60+
rethrow;
6061
}
6162
}
6263
}

lib/src/internal/network/websocket/websocket_client.dart

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,10 +107,12 @@ class WebSocketClient {
107107
}
108108

109109
void send(String data) {
110+
if (!_isConnected) {
111+
throw WebSocketFailedException();
112+
}
113+
110114
try {
111-
if (_isConnected) {
112-
_webSocketChannel?.sink.add(data);
113-
}
115+
_webSocketChannel?.sink.add(data);
114116
} catch (e) {
115117
sbLog.e(StackTrace.current, 'e: $e');
116118
throw WebSocketFailedException(message: e.toString());

lib/src/public/core/channel/base_channel/base_channel.dart

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,5 +211,8 @@ abstract class BaseChannel implements Cacheable {
211211
customType = others.customType;
212212
isFrozen = others.isFrozen;
213213
isEphemeral = others.isEphemeral;
214+
215+
fromCache = others.fromCache;
216+
dirty = others.dirty;
214217
}
215218
}

0 commit comments

Comments
 (0)