Index: lib/src/isolate.dart |
diff --git a/lib/src/isolate.dart b/lib/src/isolate.dart |
index d9363daa37947af26664dde7e475026e8286fba8..1d4792ff9f93bce77119c7e818dc3f6e1dc97c0a 100644 |
--- a/lib/src/isolate.dart |
+++ b/lib/src/isolate.dart |
@@ -19,6 +19,7 @@ import 'sentinel.dart'; |
import 'stack.dart'; |
import 'stream_manager.dart'; |
import 'utils.dart'; |
+import 'extension.dart'; |
VMIsolateRef newVMIsolateRef(rpc.Peer peer, StreamManager streams, Map json) { |
if (json == null) return null; |
@@ -86,6 +87,11 @@ class VMIsolateRef { |
Stream<List<int>> get stderr => _stderr; |
Stream<List<int>> _stderr; |
+ /// A broadcast stream that emits the name of VM service extensions |
+ Stream<VMServiceExtension> get onServiceExtensionAdded => |
+ _onServiceExtensionAdded; |
+ Stream<VMServiceExtension> _onServiceExtensionAdded; |
+ |
/// A future that fires when the isolate exits. |
/// |
/// If the isolate has already exited, this will complete immediately. |
@@ -126,6 +132,11 @@ class VMIsolateRef { |
sink.add(new VMIsolateRef._(_scope, json["isolate"])); |
}); |
+ _onServiceExtensionAdded = _transform(_scope.streams.isolate, (json, sink) { |
+ if (json["kind"] != "ServiceExtensionAdded") return; |
+ sink.add(newVMServiceExtension(json["extensionRPC"])); |
+ }); |
+ |
_onPauseOrResume = _transform(_scope.streams.debug, (json, sink) { |
var event = newVMPauseEvent(_scope, json); |
if (event != null) sink.add(event); |
@@ -264,6 +275,22 @@ class VMIsolateRef { |
} |
} |
+ /// Makes a raw RPC to a VM service extension registered in this isolate |
+ /// corresponding to the ID [number]. |
+ /// |
+ /// [method] must correspond to a VM service extension installed on the VM |
+ /// isolate and it must begin with prefix "ext.". |
+ /// |
+ /// [params] are passed to the extension handler and must be serializable to |
+ /// a JSON string. |
+ Future<Object> invokeExtension(String method, [Map<String, String> params]) { |
+ if (!method.startsWith('ext.')) { |
+ throw new ArgumentError.value(method, 'method', |
+ 'must begin with "ext." prefix'); |
+ } |
+ return _scope.sendRequest(method, params); |
+ } |
+ |
bool operator ==(other) => other is VMIsolateRef && |
other._scope.isolateId == _scope.isolateId; |
@@ -365,4 +392,4 @@ class VMStep { |
const VMStep._(this._value); |
String toString() => _value; |
-} |
+} |