| 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 library vmservice; | 5 library vmservice; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 import 'dart:convert'; | 8 import 'dart:convert'; |
| 9 import 'dart:isolate'; | 9 import 'dart:isolate'; |
| 10 import 'dart:typed_data'; | 10 import 'dart:typed_data'; |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 149 static const _kStreamNotSubscribed = 104; | 149 static const _kStreamNotSubscribed = 104; |
| 150 | 150 |
| 151 var _errorMessages = { | 151 var _errorMessages = { |
| 152 _kInvalidParams: 'Invalid params"', | 152 _kInvalidParams: 'Invalid params"', |
| 153 _kStreamAlreadySubscribed: 'Stream already subscribed', | 153 _kStreamAlreadySubscribed: 'Stream already subscribed', |
| 154 _kStreamNotSubscribed: 'Stream not subscribed', | 154 _kStreamNotSubscribed: 'Stream not subscribed', |
| 155 }; | 155 }; |
| 156 | 156 |
| 157 String _encodeError(Message message, int code, {String details}) { | 157 String _encodeError(Message message, int code, {String details}) { |
| 158 var response = { | 158 var response = { |
| 159 'jsonrpc': '2.0', |
| 159 'id' : message.serial, | 160 'id' : message.serial, |
| 160 'error' : { | 161 'error' : { |
| 161 'code': code, | 162 'code': code, |
| 162 'message': _errorMessages[code], | 163 'message': _errorMessages[code], |
| 163 }, | 164 }, |
| 164 }; | 165 }; |
| 165 if (details != null) { | 166 if (details != null) { |
| 166 response['error']['data'] = { | 167 response['error']['data'] = { |
| 167 'details': details, | 168 'details': details, |
| 168 }; | 169 }; |
| 169 } | 170 } |
| 170 return JSON.encode(response); | 171 return JSON.encode(response); |
| 171 } | 172 } |
| 172 | 173 |
| 173 String _encodeResult(Message message, Map result) { | 174 String _encodeResult(Message message, Map result) { |
| 174 var response = { | 175 var response = { |
| 176 'jsonrpc': '2.0', |
| 175 'id' : message.serial, | 177 'id' : message.serial, |
| 176 'result' : result, | 178 'result' : result, |
| 177 }; | 179 }; |
| 178 return JSON.encode(response); | 180 return JSON.encode(response); |
| 179 } | 181 } |
| 180 | 182 |
| 181 bool _isAnyClientSubscribed(String streamId) { | 183 bool _isAnyClientSubscribed(String streamId) { |
| 182 for (var client in clients) { | 184 for (var client in clients) { |
| 183 if (client.streams.contains(streamId)) { | 185 if (client.streams.contains(streamId)) { |
| 184 return true; | 186 return true; |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 316 service.runningIsolates.isolateStartup(port_id, sp, name); | 318 service.runningIsolates.isolateStartup(port_id, sp, name); |
| 317 } | 319 } |
| 318 | 320 |
| 319 void _onStart() native "VMService_OnStart"; | 321 void _onStart() native "VMService_OnStart"; |
| 320 | 322 |
| 321 void _onExit() native "VMService_OnExit"; | 323 void _onExit() native "VMService_OnExit"; |
| 322 | 324 |
| 323 bool _vmListenStream(String streamId) native "VMService_ListenStream"; | 325 bool _vmListenStream(String streamId) native "VMService_ListenStream"; |
| 324 | 326 |
| 325 void _vmCancelStream(String streamId) native "VMService_CancelStream"; | 327 void _vmCancelStream(String streamId) native "VMService_CancelStream"; |
| OLD | NEW |