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

Side by Side Diff: runtime/bin/vmservice/server.dart

Issue 897193002: Finish moving service protocol to json rpc. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: code review Created 5 years, 10 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/main.cc ('k') | runtime/include/dart_api.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 part of vmservice_io; 5 part of vmservice_io;
6 6
7 class WebSocketClient extends Client { 7 class WebSocketClient extends Client {
8 static const int PARSE_ERROR_CODE = 4000; 8 static const int PARSE_ERROR_CODE = 4000;
9 static const int BINARY_MESSAGE_ERROR_CODE = 4001; 9 static const int BINARY_MESSAGE_ERROR_CODE = 4001;
10 static const int NOT_MAP_ERROR_CODE = 4002; 10 static const int NOT_MAP_ERROR_CODE = 4002;
(...skipping 14 matching lines...) Expand all
25 } catch (e) { 25 } catch (e) {
26 socket.close(PARSE_ERROR_CODE, 'Message parse error: $e'); 26 socket.close(PARSE_ERROR_CODE, 'Message parse error: $e');
27 return; 27 return;
28 } 28 }
29 if (map is! Map) { 29 if (map is! Map) {
30 socket.close(NOT_MAP_ERROR_CODE, 'Message must be a JSON map.'); 30 socket.close(NOT_MAP_ERROR_CODE, 'Message must be a JSON map.');
31 return; 31 return;
32 } 32 }
33 var serial = map['id']; 33 var serial = map['id'];
34 34
35 // If the map contains 'params' then this is a JsonRPC message. 35 onMessage(serial, new Message.fromJsonRpc(map['method'], map['params']));
36 // We are currently in the process of switching the vmservice over to
37 // JsonRPC.
38 if (map['params'] != null) {
39 onMessage(serial, new Message.fromJsonRpc(map['method'],
40 map['params']));
41 } else {
42 onMessage(serial, new Message.fromUri(Uri.parse(map['method'])));
43 }
44 } else { 36 } else {
45 socket.close(BINARY_MESSAGE_ERROR_CODE, 'Message must be a string.'); 37 socket.close(BINARY_MESSAGE_ERROR_CODE, 'Message must be a string.');
46 } 38 }
47 } 39 }
48 40
49 void post(var serial, dynamic response) { 41 void post(var serial, dynamic response) {
50 try { 42 try {
51 Map map = { 43 Map map = {
52 'id': serial, 44 'id': serial,
53 'response': response 45 'response': response
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 _server = null; 204 _server = null;
213 print('Could not shutdown Observatory HTTP server:\n$e\n$st\n'); 205 print('Could not shutdown Observatory HTTP server:\n$e\n$st\n');
214 _notifyServerState("", 0); 206 _notifyServerState("", 0);
215 return this; 207 return this;
216 }); 208 });
217 } 209 }
218 210
219 } 211 }
220 212
221 void _notifyServerState(String ip, int port) 213 void _notifyServerState(String ip, int port)
222 native "VMServiceIO_NotifyServerState"; 214 native "VMServiceIO_NotifyServerState";
OLDNEW
« no previous file with comments | « runtime/bin/main.cc ('k') | runtime/include/dart_api.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698