| 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 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 165 _sendAllDelayedRequests(); | 165 _sendAllDelayedRequests(); |
| 166 _notifyConnect(); | 166 _notifyConnect(); |
| 167 } | 167 } |
| 168 | 168 |
| 169 // WebSocket message event handler. | 169 // WebSocket message event handler. |
| 170 void _onMessage(dynamic data) { | 170 void _onMessage(dynamic data) { |
| 171 if (data is! String) { | 171 if (data is! String) { |
| 172 _webSocket.nonStringToByteData(data).then((ByteData bytes) { | 172 _webSocket.nonStringToByteData(data).then((ByteData bytes) { |
| 173 // See format spec. in VMs Service::SendEvent. | 173 // See format spec. in VMs Service::SendEvent. |
| 174 int offset = 0; | 174 int offset = 0; |
| 175 int metaSize = bytes.getUint64(offset, Endianness.BIG_ENDIAN); | 175 // Dart2JS workaround (no getUint64). Limit to 4 GB metadata. |
| 176 assert(bytes.getUint32(offset, Endianness.BIG_ENDIAN) == 0); |
| 177 int metaSize = bytes.getUint32(offset + 4, Endianness.BIG_ENDIAN); |
| 176 offset += 8; | 178 offset += 8; |
| 177 var meta = _utf8Decoder.convert(new Uint8List.view( | 179 var meta = _utf8Decoder.convert(new Uint8List.view( |
| 178 bytes.buffer, bytes.offsetInBytes + offset, metaSize)); | 180 bytes.buffer, bytes.offsetInBytes + offset, metaSize)); |
| 179 offset += metaSize; | 181 offset += metaSize; |
| 180 var data = new ByteData.view( | 182 var data = new ByteData.view( |
| 181 bytes.buffer, | 183 bytes.buffer, |
| 182 bytes.offsetInBytes + offset, | 184 bytes.offsetInBytes + offset, |
| 183 bytes.lengthInBytes - offset); | 185 bytes.lengthInBytes - offset); |
| 184 postEventMessage(meta, data); | 186 postEventMessage(meta, data); |
| 185 }); | 187 }); |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 281 'query': request.id | 283 'query': request.id |
| 282 } | 284 } |
| 283 }); | 285 }); |
| 284 } else { | 286 } else { |
| 285 message = JSON.encode({'seq': serial, 'request': request.id}); | 287 message = JSON.encode({'seq': serial, 'request': request.id}); |
| 286 } | 288 } |
| 287 // Send message. | 289 // Send message. |
| 288 _webSocket.send(message); | 290 _webSocket.send(message); |
| 289 } | 291 } |
| 290 } | 292 } |
| OLD | NEW |