| OLD | NEW |
| 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 13 matching lines...) Expand all Loading... |
| 24 map = JSON.decode(message); | 24 map = JSON.decode(message); |
| 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 onMessage(serial, new Message.fromJsonRpc(map)); |
| 35 onMessage(serial, new Message.fromJsonRpc(map['method'], map['params'])); | |
| 36 } else { | 35 } else { |
| 37 socket.close(BINARY_MESSAGE_ERROR_CODE, 'Message must be a string.'); | 36 socket.close(BINARY_MESSAGE_ERROR_CODE, 'Message must be a string.'); |
| 38 } | 37 } |
| 39 } | 38 } |
| 40 | 39 |
| 41 void post(var serial, dynamic response) { | 40 void post(var serial, dynamic response) { |
| 42 try { | 41 try { |
| 43 Map map = { | 42 Map map = { |
| 44 'id': serial, | 43 'id': serial, |
| 45 'response': response | 44 'response': response |
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 205 print('Could not shutdown Observatory HTTP server:\n$e\n$st\n'); | 204 print('Could not shutdown Observatory HTTP server:\n$e\n$st\n'); |
| 206 _notifyServerState("", 0); | 205 _notifyServerState("", 0); |
| 207 return this; | 206 return this; |
| 208 }); | 207 }); |
| 209 } | 208 } |
| 210 | 209 |
| 211 } | 210 } |
| 212 | 211 |
| 213 void _notifyServerState(String ip, int port) | 212 void _notifyServerState(String ip, int port) |
| 214 native "VMServiceIO_NotifyServerState"; | 213 native "VMServiceIO_NotifyServerState"; |
| OLD | NEW |