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

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

Issue 474633002: Optional binary payloads in VM service events. (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
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 19 matching lines...) Expand all
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 seq = map['seq']; 33 var seq = map['seq'];
34 onMessage(seq, new Message.fromUri(Uri.parse(map['request']))); 34 onMessage(seq, new Message.fromUri(Uri.parse(map['request'])));
35 } else { 35 } else {
36 socket.close(BINARY_MESSAGE_ERROR_CODE, 'Message must be a string.'); 36 socket.close(BINARY_MESSAGE_ERROR_CODE, 'Message must be a string.');
37 } 37 }
38 } 38 }
39 39
40 void post(var seq, String response) { 40 void post(var seq, dynamic response) {
41 try { 41 try {
42 Map map = { 42 Map map = {
43 'seq': seq, 43 'seq': seq,
44 'response': response 44 'response': response
45 }; 45 };
46 socket.add(JSON.encode(map)); 46 if (seq == null && response is! String) {
47 socket.add(response);
48 } else {
49 socket.add(JSON.encode(map));
50 }
47 } catch (_) { 51 } catch (_) {
48 // Error posting over WebSocket. 52 print("Ignoring error posting over WebSocket.");
49 } 53 }
50 } 54 }
51 55
52 dynamic toJson() { 56 dynamic toJson() {
53 Map map = super.toJson(); 57 Map map = super.toJson();
54 map['type'] = 'WebSocketClient'; 58 map['type'] = 'WebSocketClient';
55 map['socket'] = '$socket'; 59 map['socket'] = '$socket';
56 return map; 60 return map;
57 } 61 }
58 } 62 }
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
193 _server = null; 197 _server = null;
194 return this; 198 return this;
195 }).catchError((e, st) { 199 }).catchError((e, st) {
196 _server = null; 200 _server = null;
197 print('Could not shutdown Observatory HTTP server:\n$e\n$st\n'); 201 print('Could not shutdown Observatory HTTP server:\n$e\n$st\n');
198 return this; 202 return this;
199 }); 203 });
200 } 204 }
201 205
202 } 206 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698