Skip to content

Commit

Permalink
chore: bump version 1.3.17
Browse files Browse the repository at this point in the history
  • Loading branch information
lambiengcode committed May 30, 2024
1 parent 00357d1 commit fccc7c2
Show file tree
Hide file tree
Showing 13 changed files with 55 additions and 28 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## 1.3.17

* Upgrade flutter_webrtc to support GPUPixel on Android
* Fix socket connection

## 1.3.16

* Refactor: websocket connection
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Flutter plugin of [Waterbus](https://docs.waterbus.tech). Build video call or on

| Feature | Subscribe/Publish | Screen Sharing | Picture in Picture | Virtual Background | Beauty Filters | End to End Encryption |
| ------------------ | ----------------- | -------------- | ------------------ | ------------------ | -------------- | --------------------- |
| Android | 🟢 | 🟢 | 🟢 | 🟢 | 🟡 | 🟢 |
| Android | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 |
| iOS | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 |
| MacOS | 🟢 | 🟢 | 🔴 | 🟢 | 🟢 | 🟢 |
| Web | 🟢 | 🟢 | 🟢 | 🟢 | 🟡 | 🟢 |
Expand Down
4 changes: 2 additions & 2 deletions lib/core/api/auth/datasources/auth_local_datasource.dart
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ class AuthLocalDataSourceImpl implements AuthLocalDataSource {

@override
String get accessToken =>
_hiveBox.get(StorageKeys.accessToken, defaultValue: null) ?? "";
_hiveBox.get(StorageKeys.accessToken, defaultValue: "");

@override
String get refreshToken =>
_hiveBox.get(StorageKeys.refreshToken, defaultValue: null) ?? "";
_hiveBox.get(StorageKeys.refreshToken, defaultValue: "");
}
22 changes: 11 additions & 11 deletions lib/core/api/base/dio_configuration.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ import 'package:waterbus_sdk/core/api/base/base_remote_data.dart';
import 'package:waterbus_sdk/utils/extensions/duration_extensions.dart';
import 'package:waterbus_sdk/utils/queues/completer_queue.dart';

typedef TokensCallback = Function(
String accessToken,
String refreshToken,
);

@singleton
class DioConfiguration {
final BaseRemoteData _remoteData;
Expand Down Expand Up @@ -56,8 +61,9 @@ class DioConfiguration {
final String oldAccessToken =
response.requestOptions.headers['Authorization'];

final (String accessToken, String _) =
await onRefreshToken(oldAccessToken: oldAccessToken);
final (String accessToken, String _) = await onRefreshToken(
oldAccessToken: oldAccessToken.split(' ').last,
);

response.requestOptions.headers['Authorization'] =
'Bearer $accessToken';
Expand Down Expand Up @@ -88,12 +94,9 @@ class DioConfiguration {

Future<(String, String)> onRefreshToken({
String oldAccessToken = '',
Function(
String accessToken,
String refreshToken,
)? callback,
TokensCallback? callback,
}) async {
if (oldAccessToken != 'Bearer ${_authLocal.accessToken}') {
if (oldAccessToken != _authLocal.accessToken) {
return (_authLocal.accessToken, _authLocal.refreshToken);
}

Expand All @@ -116,10 +119,7 @@ class DioConfiguration {

// MARK: Private methods
Future<(String, String)> _performRefreshToken({
Function(
String accessToken,
String refreshToken,
)? callback,
TokensCallback? callback,
}) async {
if (_authLocal.refreshToken.isEmpty) {
if (_authLocal.accessToken.isNotEmpty) {
Expand Down
2 changes: 1 addition & 1 deletion lib/core/webrtc/webrtc.dart
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ class WaterbusWebRTCManagerIpml extends WaterbusWebRTCManager {
participant: _mParticipant!,
);

_nativeService.startCallKit(roomId);
_nativeService.startCallKit(roomId.roomCodeFormatted);
_stats.initialize();
_audioStats.initialize();
}
Expand Down
2 changes: 2 additions & 0 deletions lib/core/websocket/interfaces/socket_handler_interface.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,6 @@ abstract class SocketHandler {
void disconnection();

Socket? get socket;

bool get isConnected;
}
22 changes: 17 additions & 5 deletions lib/core/websocket/socket_handler.dart
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,18 @@ class SocketHandlerImpl extends SocketHandler {
Socket? _socket;

@override
void establishConnection({bool forceConnection = false}) {
void establishConnection({
bool forceConnection = false,
String? forceAccessToken,
}) {
if (_authLocal.accessToken.isEmpty ||
(_socket != null && !forceConnection)) {
return;
}

final String mAccessToken = _authLocal.accessToken;
disconnection();

final String mAccessToken = forceAccessToken ?? _authLocal.accessToken;

_socket = io(
WaterbusSdk.wsUrl,
Expand All @@ -51,10 +56,14 @@ class SocketHandlerImpl extends SocketHandler {
_socket?.onError((data) async {
if (_authLocal.accessToken.isEmpty) return;

final (_, _) =
await _dioConfig.onRefreshToken(oldAccessToken: mAccessToken);
final (String newAccessToken, _) = await _dioConfig.onRefreshToken(
oldAccessToken: mAccessToken,
);

establishConnection();
establishConnection(
forceConnection: true,
forceAccessToken: newAccessToken,
);
});

_socket?.onConnect((_) async {
Expand Down Expand Up @@ -241,4 +250,7 @@ class SocketHandlerImpl extends SocketHandler {

@override
Socket? get socket => _socket;

@override
bool get isConnected => _socket != null && _socket!.connected;
}
8 changes: 4 additions & 4 deletions lib/types/enums/video_quality.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ extension VideoQualityX on VideoQuality {
// VGA
case VideoQuality.low:
return {
'minHeight': '480',
'minWidth': '640',
'minHeight': '360',
'minWidth': '480',
'minFrameRate': '15',
'frameRate': '15',
'height': '720',
'width': '1280',
'height': '480',
'width': '800',
};
// SVGA
case VideoQuality.auto:
Expand Down
1 change: 1 addition & 0 deletions lib/types/extensions/index.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export './string_ext.dart';
6 changes: 6 additions & 0 deletions lib/types/extensions/string_ext.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
extension StringX on String {
String get roomCodeFormatted {
final String paddedCode = padLeft(9, '0');
return "${paddedCode.substring(0, 3)}-${paddedCode.substring(3, 6)}-${paddedCode.substring(6)}";
}
}
1 change: 1 addition & 0 deletions lib/types/index.dart
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
export './models/index.dart';
export './enums/index.dart';
export './extensions/index.dart';
4 changes: 2 additions & 2 deletions lib/waterbus_sdk_impl.dart
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class SdkCore extends WaterbusSdkInterface {
await _baseLocalData.initialize();
await _baseRepository.initialize();

_webSocket.establishConnection();
_webSocket.establishConnection(forceConnection: true);

_rtcManager.notifyChanged.listen((event) {
WaterbusSdk.onEventChanged?.call(event);
Expand Down Expand Up @@ -76,7 +76,7 @@ class SdkCore extends WaterbusSdkInterface {
required String password,
required int? userId,
}) async {
if (!(_webSocket.socket?.connected ?? false)) return null;
if (!_webSocket.isConnected) return null;

late final Meeting? room;

Expand Down
4 changes: 2 additions & 2 deletions pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: waterbus_sdk
description: Flutter plugin of Waterbus. Build video call or online meeting application with SFU model. Supports iOS, Android.
version: 1.3.16
version: 1.3.17
homepage: https://docs.waterbus.tech
repository: https://github.com/waterbustech/waterbus-flutter-sdk
issue_tracker: https://github.com/waterbustech/waterbus-flutter-sdk/issues
Expand Down Expand Up @@ -39,7 +39,7 @@ dependencies:
sdp_transform: ^0.3.2
h264_profile_level_id: ^0.2.1
dart_webrtc_plus: ^1.4.4+2
flutter_webrtc_plus: ^0.10.3+6
flutter_webrtc_plus: ^0.10.3+9
# flutter_webrtc_plus:
# path: /Users/lambiengcode/Documents/webrtc/flutter-webrtc

Expand Down

0 comments on commit fccc7c2

Please sign in to comment.