Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add support to latest flutter version #15

Merged
merged 1 commit into from
Dec 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ jobs:
future_release: ${{ needs.auto-gen-tag.outputs.tag }}
since_tag: ${{ steps.get_latest_release.outputs.release }}
- name: Upload changelog
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v4
with:
name: changelog
path: CHANGELOG.md
Expand All @@ -57,7 +57,7 @@ jobs:
steps:
- run: echo ${{needs.auto-gen-tag.outputs.tag}}
- name: Download changelog
uses: actions/download-artifact@v2
uses: actions/download-artifact@v4
with:
name: changelog
- name: Draft release with changelog
Expand All @@ -80,7 +80,7 @@ jobs:
- uses: actions/checkout@v3
- uses: subosito/flutter-action@v2
with:
flutter-version: '3.7.8'
flutter-version: '3.27.0'
- name: Install dependencies
run: flutter pub get
- name: Run tests
Expand All @@ -95,7 +95,7 @@ jobs:
- name: Install Flutter
uses: subosito/flutter-action@v2
with:
flutter-version: '3.7.8'
flutter-version: '3.27.0'
- name: Check Publish Warnings
run: dart pub publish --dry-run
- name: Publish
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
- uses: actions/checkout@v3
- uses: subosito/flutter-action@v2
with:
flutter-version: '3.7.8'
flutter-version: '3.27.0'
- name: Install dependencies
run: flutter pub get
- name: Run tests
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.0.27

- Upgraded Lime version from 0.0.25 to 0.0.26 and add support to latest flutter stable version.

## 0.0.26

- Upgraded Lime version from 0.0.24 to 0.0.25.
Expand Down
3 changes: 2 additions & 1 deletion lib/blip_sdk.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
library blip_sdk;
library;

export 'package:lime/lime.dart';

export 'src/application.dart' show Application;
export 'src/client.dart' show Client;
export 'src/client_builder.dart' show ClientBuilder;
Expand Down
35 changes: 9 additions & 26 deletions lib/src/client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class Client {
final _extensions = <ExtensionType, BaseExtension>{};

late StreamController<bool> onConnectionDone;
var onListeningChanged = StreamController<bool>();
var onListeningChanged = StreamController<bool>.broadcast();

bool _listening = false;
bool _closing = false;
Expand Down Expand Up @@ -91,7 +91,7 @@ class Client {
);

final session = await _clientChannel.establishSession(
application.identifier + '@' + application.domain,
'${application.identifier}@${application.domain}',
application.instance,
application.authentication,
);
Expand All @@ -103,7 +103,7 @@ class Client {
],
);

_listening = true;
listening = true;
_connectionTryCount = 0;

return session;
Expand All @@ -113,7 +113,7 @@ class Client {
void _initializeClientChannel() {
// Allows Take an action when the connection to the server is closed
transport.onClose.stream.listen((event) async {
_listening = false;
listening = false;
if (!_closing) {
// Use an exponential backoff for the timeout
num timeout = 100 * pow(2, _connectionTryCount);
Expand Down Expand Up @@ -283,19 +283,11 @@ class Client {
Future<Session?> close() async {
Session? result;
_closing = true;

if (_clientChannel.state == SessionState.established &&
transport.socket?.closeCode == null) {
result = await _clientChannel.sendFinishingSession();
}

onListeningChanged.close();
onListeningChanged = StreamController<bool>();

_clientChannel.onConnectionDone.close();
_clientChannel.onConnectionDone = StreamController<bool>();
onConnectionDone = _clientChannel.onConnectionDone;

await transport.close();

return result;
Expand Down Expand Up @@ -475,33 +467,24 @@ class Client {

/// Allows to get a extension
T _getExtension<T extends BaseExtension>(ExtensionType type, String to) {
var _extension = _extensions[type];
if (_extension == null) {
var extension = _extensions[type];
if (extension == null) {
switch (type) {
case ExtensionType.media:
_extension = MediaExtension(this, to);
extension = MediaExtension(this, to);
break;
}

_extensions[type] = _extension;
_extensions[type] = extension;
}
return _extension as T;
return extension as T;
}

/// Returns a media extension
MediaExtension get media =>
_getExtension<MediaExtension>(ExtensionType.media, application.domain);

Future<void> _onConnect() async {
transport.onEnvelope?.close();
transport.onEnvelope = StreamController<Map<String, dynamic>>();

transport.onConnectionDone?.close();
transport.onConnectionDone = StreamController<bool>();

transport.onClose.close();
transport.onClose = StreamController<bool>();

_clientChannel = ClientChannel(transport);

_initializeClientChannel();
Expand Down
44 changes: 36 additions & 8 deletions lib/src/extensions/media/media.extension.dart
Original file line number Diff line number Diff line change
@@ -1,25 +1,53 @@
import 'package:lime/lime.dart';

import '../../client.dart';
import '../base.extension.dart';
import 'uri_templates.dart';

const postmasterName = 'postmaster';
const postmasterDomain = 'media';

class MediaExtension extends BaseExtension {
MediaExtension(final Client client, final String domain)
: super(client,
to: Node(
name: postmasterName, domain: '$postmasterDomain.$domain'));
MediaExtension(super.client, final String domain)
: super(
to: Node(
name: postmasterName,
domain: '$postmasterDomain.$domain',
),
);

Future<Command> getUploadToken({bool secure = false}) {
return processCommand(createGetCommand(
buildResourceQuery(UriTemplates.mediaUpload, {'secure': secure})));
return processCommand(
buildUploadTokenComand(
secure: secure,
),
);
}

Command buildUploadTokenComand({bool secure = false}) {
return createGetCommand(
buildResourceQuery(
UriTemplates.mediaUpload,
{
'secure': secure,
},
),
);
}

Future<Command> refreshMedia(id) {
return processCommand(
createGetCommand(buildUri(UriTemplates.refreshMedia, [id])));
buildRefreshMediaCommand(id),
);
}

Command buildRefreshMediaCommand(id) {
return createGetCommand(
buildUri(
UriTemplates.refreshMedia,
[
id,
],
),
);
}
}
Loading
Loading