| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 class _WebSocketMessageType { | 5 class _WebSocketMessageType { |
| 6 static final int NONE = 0; | 6 static final int NONE = 0; |
| 7 static final int BINARY = 1; | 7 static final int BINARY = 1; |
| 8 static final int TEXT = 2; | 8 static final int TEXT = 2; |
| 9 static final int CLOSE = 3; | 9 static final int CLOSE = 3; |
| 10 } | 10 } |
| (...skipping 481 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 492 if (_onError != null) _onError(e); | 492 if (_onError != null) _onError(e); |
| 493 _socket.close(); | 493 _socket.close(); |
| 494 } | 494 } |
| 495 | 495 |
| 496 _sendFrame(int opcode, List<int> data) { | 496 _sendFrame(int opcode, List<int> data) { |
| 497 bool mask = false; // Masking not implemented for server. | 497 bool mask = false; // Masking not implemented for server. |
| 498 int dataLength = data == null ? 0 : data.length; | 498 int dataLength = data == null ? 0 : data.length; |
| 499 // Determine the header size. | 499 // Determine the header size. |
| 500 int headerSize = (mask) ? 6 : 2; | 500 int headerSize = (mask) ? 6 : 2; |
| 501 if (dataLength > 65535) { | 501 if (dataLength > 65535) { |
| 502 headerSize += 4; | 502 headerSize += 8; |
| 503 } else if (dataLength > 126) { | 503 } else if (dataLength > 126) { |
| 504 headerSize += 2; | 504 headerSize += 2; |
| 505 } | 505 } |
| 506 List<int> header = new List<int>(headerSize); | 506 List<int> header = new List<int>(headerSize); |
| 507 int index = 0; | 507 int index = 0; |
| 508 // Set FIN and opcode. | 508 // Set FIN and opcode. |
| 509 header[index++] = 0x80 | opcode; | 509 header[index++] = 0x80 | opcode; |
| 510 // Determine size and position of length field. | 510 // Determine size and position of length field. |
| 511 int lengthBytes = 1; | 511 int lengthBytes = 1; |
| 512 int firstLengthByte = 1; | 512 int firstLengthByte = 1; |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 590 } | 590 } |
| 591 String key = request.headers.value("Sec-WebSocket-Key"); | 591 String key = request.headers.value("Sec-WebSocket-Key"); |
| 592 if (key == null) { | 592 if (key == null) { |
| 593 return false; | 593 return false; |
| 594 } | 594 } |
| 595 return true; | 595 return true; |
| 596 } | 596 } |
| 597 | 597 |
| 598 Function _onOpen; | 598 Function _onOpen; |
| 599 } | 599 } |
| OLD | NEW |