| 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 dart.io; | 5 part of dart.io; |
| 6 | 6 |
| 7 const String _webSocketGUID = "258EAFA5-E914-47DA-95CA-C5AB0DC85B11"; | 7 const String _webSocketGUID = "258EAFA5-E914-47DA-95CA-C5AB0DC85B11"; |
| 8 | 8 |
| 9 class _WebSocketMessageType { | 9 class _WebSocketMessageType { |
| 10 static const int NONE = 0; | 10 static const int NONE = 0; |
| (...skipping 641 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 652 } else if (dataLength > 125) { | 652 } else if (dataLength > 125) { |
| 653 header[index++] = 126; | 653 header[index++] = 126; |
| 654 lengthBytes = 2; | 654 lengthBytes = 2; |
| 655 } | 655 } |
| 656 // Write the length in network byte order into the header. | 656 // Write the length in network byte order into the header. |
| 657 for (int i = 0; i < lengthBytes; i++) { | 657 for (int i = 0; i < lengthBytes; i++) { |
| 658 header[index++] = dataLength >> (((lengthBytes - 1) - i) * 8) & 0xFF; | 658 header[index++] = dataLength >> (((lengthBytes - 1) - i) * 8) & 0xFF; |
| 659 } | 659 } |
| 660 assert(index == headerSize); | 660 assert(index == headerSize); |
| 661 try { | 661 try { |
| 662 _socket.add(header); | 662 _socket.writeBytes(header); |
| 663 if (data != null) { | 663 if (data != null) { |
| 664 _socket.add(data); | 664 _socket.writeBytes(data); |
| 665 } | 665 } |
| 666 } catch (_) { | 666 } catch (_) { |
| 667 // The socket can be closed before _socket.done have a chance | 667 // The socket can be closed before _socket.done have a chance |
| 668 // to complete. | 668 // to complete. |
| 669 _writeClosed = true; | 669 _writeClosed = true; |
| 670 } | 670 } |
| 671 } | 671 } |
| 672 } | 672 } |
| OLD | NEW |