| OLD | NEW |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 library shell; | 5 library shell; |
| 6 | 6 |
| 7 import 'package:observatory/service_io.dart'; | 7 import 'package:observatory/service_io.dart'; |
| 8 | 8 |
| 9 import 'dart:io'; | 9 import 'dart:io'; |
| 10 | 10 |
| 11 // Simple demo for service_io library. Connects to localhost on the default | 11 // Simple demo for service_io library. Connects to localhost on the default |
| 12 // port, picks the first isolate, reads requests from stdin, and prints | 12 // port, picks the first isolate, reads requests from stdin, and prints |
| 13 // results to stdout. Example session: | 13 // results to stdout. Example session: |
| 14 // <<< prefix /isolates/1071334835 | 14 // <<< prefix /isolates/1071334835 |
| 15 // >>> /classes/40 | 15 // >>> /classes/40 |
| 16 // <<< {"type":"Class","id":"classes\/40","name":"num","user_name":"num",... | 16 // <<< {"type":"Class","id":"classes\/40","name":"num","user_name":"num",... |
| 17 // >>> /objects/0 | 17 // >>> /objects/0 |
| 18 // >>> {"type":"Array","class":{"type":"@Class","id":"classes\/62",... | 18 // >>> {"type":"Array","class":{"type":"@Class","id":"classes\/62",... |
| 19 | 19 |
| 20 void repl(VM vm, String prefix, String lastResult) { | 20 void repl(VM vm, String prefix, String lastResult) { |
| 21 print(lastResult); | 21 print(lastResult); |
| 22 // TODO(koda): Use 'get' when ServiceObjects have more informative toString. | 22 // TODO(turnidge): use the non-deprecated api here. |
| 23 vm.getString(prefix + stdin.readLineSync()).then((String result) { | 23 vm.getStringDeprecated(prefix + stdin.readLineSync()).then((String result) { |
| 24 repl(vm, prefix, result); | 24 repl(vm, prefix, result); |
| 25 }); | 25 }); |
| 26 } | 26 } |
| 27 | 27 |
| 28 void main() { | 28 void main() { |
| 29 String addr = 'ws://localhost:8181/ws'; | 29 String addr = 'ws://localhost:8181/ws'; |
| 30 new WebSocketVM(new WebSocketVMTarget(addr)).get('vm').then((VM vm) { | 30 new WebSocketVM(new WebSocketVMTarget(addr)).load().then((VM vm) { |
| 31 Isolate isolate = vm.isolates.first; | 31 Isolate isolate = vm.isolates.first; |
| 32 String prefix = '${isolate.link}'; | 32 String prefix = '${isolate.link}'; |
| 33 repl(vm, prefix, 'prefix $prefix'); | 33 repl(vm, prefix, 'prefix $prefix'); |
| 34 }); | 34 }); |
| 35 } | 35 } |
| OLD | NEW |