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

Side by Side Diff: runtime/bin/vmservice/client/lib/service_io.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, 4 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « runtime/bin/vmservice/client/lib/service_html.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // BSD-style license that can be found in the LICENSE file.
4
5 library service_io;
6
7 import 'dart:io';
8
9 import 'package:observatory/service_common.dart';
10
11 // Export the service library.
12 export 'package:observatory/service_common.dart';
13
14 class _IOWebSocket implements CommonWebSocket {
15 WebSocket _webSocket;
16
17 void connect(String address,
18 void onOpen(),
19 void onMessage(dynamic data),
20 void onError(),
21 void onClose()) {
22 WebSocket.connect(address).then((WebSocket socket) {
23 _webSocket = socket;
24 _webSocket.listen(
25 onMessage,
26 onError: (dynamic) => onError(),
27 onDone: onClose,
28 cancelOnError: true);
29 onOpen();
30 });
31 }
32
33 bool get isOpen =>
34 (_webSocket != null) && (_webSocket.readyState == WebSocket.OPEN);
35
36 void send(dynamic data) {
37 _webSocket.add(data);
38 }
39
40 void close() {
41 _webSocket.close();
42 }
43 }
44
45 /// The [WebSocketVM] communicates with a Dart VM over WebSocket. The Dart VM
46 /// can be embedded in Chromium or standalone. In the case of Chromium, we
47 /// make the service requests via the Chrome Remote Debugging Protocol.
48 class WebSocketVM extends CommonWebSocketVM {
49 WebSocketVM(WebSocketVMTarget target) : super(target, new _IOWebSocket());
50 }
OLDNEW
« no previous file with comments | « runtime/bin/vmservice/client/lib/service_html.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698