mirror of
https://github.com/dart-lang/sdk
synced 2024-09-23 03:13:47 +00:00
8ebad12515
BUG= R=johnmccutchan@google.com Review URL: https://codereview.chromium.org//899303002 git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@43515 260f80e4-7a28-3924-810f-c04153c831b5
37 lines
1.2 KiB
Dart
37 lines
1.2 KiB
Dart
// Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
|
|
// 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.
|
|
|
|
library shell;
|
|
|
|
import 'package:observatory/service_io.dart';
|
|
|
|
import 'dart:io';
|
|
|
|
// Simple demo for service_io library. Connects to localhost on the default
|
|
// port, picks the first isolate, reads requests from stdin, and prints
|
|
// results to stdout. Example session:
|
|
// <<< isolate isolates/1071334835
|
|
// >>> /classes/40
|
|
// <<< {"type":"Class","id":"classes\/40","name":"num","user_name":"num",...
|
|
// >>> /objects/0
|
|
// >>> {"type":"Array","class":{"type":"@Class","id":"classes\/62",...
|
|
|
|
void repl(VM vm, Isolate isolate, String lastResult) {
|
|
print(lastResult);
|
|
Map params = {
|
|
'objectId': stdin.readLineSync(),
|
|
};
|
|
isolate.invokeRpcNoUpgrade('getObject', params).then((Map result) {
|
|
repl(vm, isolate, result.toString());
|
|
});
|
|
}
|
|
|
|
void main() {
|
|
String addr = 'ws://localhost:8181/ws';
|
|
new WebSocketVM(new WebSocketVMTarget(addr)).load().then((VM vm) {
|
|
Isolate isolate = vm.isolates.first;
|
|
repl(vm, isolate, 'isolate ${isolate.id}');
|
|
});
|
|
}
|