| OLD | NEW |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 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 | 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 service_common; | 5 library service_common; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 import 'dart:convert'; | 8 import 'dart:convert'; |
| 9 import 'dart:typed_data'; | 9 import 'dart:typed_data'; |
| 10 | 10 |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 121 Future get onDisconnect => _disconnected.future; | 121 Future get onDisconnect => _disconnected.future; |
| 122 | 122 |
| 123 void disconnect() { | 123 void disconnect() { |
| 124 if (_hasInitiatedConnect) { | 124 if (_hasInitiatedConnect) { |
| 125 _webSocket.close(); | 125 _webSocket.close(); |
| 126 } | 126 } |
| 127 _cancelAllRequests(); | 127 _cancelAllRequests(); |
| 128 _notifyDisconnect(); | 128 _notifyDisconnect(); |
| 129 } | 129 } |
| 130 | 130 |
| 131 Future<String> getString(String id) { | 131 Future<String> getStringDeprecated(String id) { |
| 132 if (!_hasInitiatedConnect) { | 132 if (!_hasInitiatedConnect) { |
| 133 _hasInitiatedConnect = true; | 133 _hasInitiatedConnect = true; |
| 134 _webSocket.connect( | 134 _webSocket.connect( |
| 135 target.networkAddress, _onOpen, _onMessage, _onError, _onClose); | 135 target.networkAddress, _onOpen, _onMessage, _onError, _onClose); |
| 136 } | 136 } |
| 137 return _makeRequest(id); | 137 return _makeRequest(id); |
| 138 } | 138 } |
| 139 | 139 |
| 140 /// Add a request for [id] to pending requests. | 140 /// Add a request for [id] to pending requests. |
| 141 Future<String> _makeRequest(String id) { | 141 Future<String> _makeRequest(String id) { |
| (...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 308 }); | 308 }); |
| 309 } else { | 309 } else { |
| 310 message = JSON.encode({'id': serial, | 310 message = JSON.encode({'id': serial, |
| 311 'method': request.method, | 311 'method': request.method, |
| 312 'params': request.params}); | 312 'params': request.params}); |
| 313 } | 313 } |
| 314 // Send message. | 314 // Send message. |
| 315 _webSocket.send(message); | 315 _webSocket.send(message); |
| 316 } | 316 } |
| 317 } | 317 } |
| OLD | NEW |