diff --git a/pkg/dart_service_protocol_shared/CHANGELOG.md b/pkg/dart_service_protocol_shared/CHANGELOG.md index b78d64c6269..06ff0ad126c 100644 --- a/pkg/dart_service_protocol_shared/CHANGELOG.md +++ b/pkg/dart_service_protocol_shared/CHANGELOG.md @@ -1,3 +1,6 @@ +## 0.0.2 +- Fixed an issue with streamNotify data type being too specific. + ## 0.0.1 - Initial version. diff --git a/pkg/dart_service_protocol_shared/lib/src/client.dart b/pkg/dart_service_protocol_shared/lib/src/client.dart index 011904155a4..c9d4b82aba5 100644 --- a/pkg/dart_service_protocol_shared/lib/src/client.dart +++ b/pkg/dart_service_protocol_shared/lib/src/client.dart @@ -11,7 +11,7 @@ abstract class Client { /// /// This method should do any formatting needed on [data], then send it to /// the [Client]. - void streamNotify(String stream, Map data); + void streamNotify(String stream, Object data); /// Called if the connection to the client should be closed. Future close(); diff --git a/pkg/dart_service_protocol_shared/lib/src/stream_manager.dart b/pkg/dart_service_protocol_shared/lib/src/stream_manager.dart index cd28cfc8844..c5b25644979 100644 --- a/pkg/dart_service_protocol_shared/lib/src/stream_manager.dart +++ b/pkg/dart_service_protocol_shared/lib/src/stream_manager.dart @@ -27,7 +27,7 @@ abstract class StreamManager { @mustCallSuper void postEvent( String stream, - Map data, { + Object data, { Client? excludedClient, }) { final listeners = _streamListeners[stream] ?? const []; diff --git a/pkg/dart_service_protocol_shared/pubspec.yaml b/pkg/dart_service_protocol_shared/pubspec.yaml index bf2299f1114..f42883db9fa 100644 --- a/pkg/dart_service_protocol_shared/pubspec.yaml +++ b/pkg/dart_service_protocol_shared/pubspec.yaml @@ -1,7 +1,7 @@ name: dart_service_protocol_shared description: A package that implements service extensions and stream managers. -version: 0.0.1 +version: 0.0.2 repository: https://github.com/dart-lang/sdk/tree/main/pkg/dart_service_protocol_shared environment: diff --git a/pkg/dart_service_protocol_shared/test/client_test.dart b/pkg/dart_service_protocol_shared/test/client_test.dart index 8efe7905840..c9fb806c9d7 100644 --- a/pkg/dart_service_protocol_shared/test/client_test.dart +++ b/pkg/dart_service_protocol_shared/test/client_test.dart @@ -25,7 +25,7 @@ class TestClient extends Client { } @override - void streamNotify(String stream, Map data) { + void streamNotify(String stream, Object data) { streamNotifyCount++; } } diff --git a/pkg/dart_service_protocol_shared/test/stream_manager_test.dart b/pkg/dart_service_protocol_shared/test/stream_manager_test.dart index 64eec28c648..96b91dd965d 100644 --- a/pkg/dart_service_protocol_shared/test/stream_manager_test.dart +++ b/pkg/dart_service_protocol_shared/test/stream_manager_test.dart @@ -2,6 +2,8 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. +import 'dart:typed_data'; + import 'package:dart_service_protocol_shared/src/client.dart'; import 'package:dart_service_protocol_shared/src/stream_manager.dart'; @@ -11,7 +13,7 @@ class TestStreamClient extends Client { int closeCount = 0; int sendRequestCount = 0; int streamNotifyCount = 0; - Map? notification; + Object? notification; @override Future close() { @@ -26,7 +28,7 @@ class TestStreamClient extends Client { } @override - void streamNotify(String stream, Map data) { + void streamNotify(String stream, Object data) { streamNotifyCount++; notification = data; } @@ -137,6 +139,23 @@ void main() { expect(clientB.notification, messageB); }); + test('postEvent can use binary data', () { + final messageA = Uint8List(4); + messageA[0] = 1; + messageA[1] = 2; + messageA[2] = 3; + messageA[3] = 4; + manager.streamListen(client, 'A'); + + manager.postEvent( + 'A', + messageA, + ); + + expect(client.streamNotifyCount, 1); + expect(client.notification, messageA); + }); + test('onClientDisconnect cancels a client from all streams', () async { final testClient = TestStreamClient(); final aClients = [