Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(240)

Unified Diff: runtime/bin/vmservice/client/bin/shell.dart

Issue 428613002: Enable using the service library from dart:io applications. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | runtime/bin/vmservice/client/deployed/web/index.html_bootstrap.dart.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/bin/vmservice/client/bin/shell.dart
===================================================================
--- runtime/bin/vmservice/client/bin/shell.dart (revision 0)
+++ runtime/bin/vmservice/client/bin/shell.dart (revision 0)
@@ -0,0 +1,35 @@
+// 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:
+// <<< prefix /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, String prefix, String lastResult) {
+ print(lastResult);
+ // TODO(koda): Use 'get' when ServiceObjects have more informative toString.
+ vm.getString(prefix + stdin.readLineSync()).then((String result) {
+ repl(vm, prefix, result);
+ });
+}
+
+void main() {
+ String addr = 'ws://localhost:8181/ws';
+ new WebSocketVM(new WebSocketVMTarget(addr)).get('vm').then((VM vm) {
+ Isolate isolate = vm.isolates.first;
+ String prefix = '${isolate.link}';
+ repl(vm, prefix, 'prefix $prefix');
+ });
+}
« no previous file with comments | « no previous file | runtime/bin/vmservice/client/deployed/web/index.html_bootstrap.dart.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698