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 const String _webSocketGUID = "258EAFA5-E914-47DA-95CA-C5AB0DC85B11"; | 5 const String _webSocketGUID = "258EAFA5-E914-47DA-95CA-C5AB0DC85B11"; |
6 | 6 |
7 class _WebSocketMessageType { | 7 class _WebSocketMessageType { |
8 static const int NONE = 0; | 8 static const int NONE = 0; |
9 static const int BINARY = 1; | 9 static const int BINARY = 1; |
10 static const int TEXT = 2; | 10 static const int TEXT = 2; |
(...skipping 450 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
461 // before closing the socket. If a close frame does not arrive | 461 // before closing the socket. If a close frame does not arrive |
462 // within a reasonable amount of time just close the socket. | 462 // within a reasonable amount of time just close the socket. |
463 _socket.outputStream.close(); | 463 _socket.outputStream.close(); |
464 _closeTimer = new Timer(5000, (t) { | 464 _closeTimer = new Timer(5000, (t) { |
465 _socket.close(); | 465 _socket.close(); |
466 }); | 466 }); |
467 } | 467 } |
468 _closeSent = true; | 468 _closeSent = true; |
469 } | 469 } |
470 | 470 |
471 int hashCode() => _hash; | 471 int get hashCode => _hash; |
472 | 472 |
473 _onWebSocketMessageStart(int type) { | 473 _onWebSocketMessageStart(int type) { |
474 _currentMessageType = type; | 474 _currentMessageType = type; |
475 if (_currentMessageType == _WebSocketMessageType.TEXT) { | 475 if (_currentMessageType == _WebSocketMessageType.TEXT) { |
476 _decoder = _StringDecoders.decoder(Encoding.UTF_8); | 476 _decoder = _StringDecoders.decoder(Encoding.UTF_8); |
477 } else { | 477 } else { |
478 _outputStream = new ListOutputStream(); | 478 _outputStream = new ListOutputStream(); |
479 } | 479 } |
480 } | 480 } |
481 | 481 |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
569 _StringDecoder _decoder; | 569 _StringDecoder _decoder; |
570 ListOutputStream _outputStream; | 570 ListOutputStream _outputStream; |
571 bool _closeReceived = false; | 571 bool _closeReceived = false; |
572 bool _closeSent = false; | 572 bool _closeSent = false; |
573 } | 573 } |
574 | 574 |
575 | 575 |
576 class _WebSocketConnection | 576 class _WebSocketConnection |
577 extends _WebSocketConnectionBase implements WebSocketConnection { | 577 extends _WebSocketConnectionBase implements WebSocketConnection { |
578 _WebSocketConnection(DetachedSocket detached) { | 578 _WebSocketConnection(DetachedSocket detached) { |
579 _hash = detached.socket.hashCode(); | 579 _hash = detached.socket.hashCode; |
580 _socketConnected(detached.socket); | 580 _socketConnected(detached.socket); |
581 _startProcessing(detached.unparsedData); | 581 _startProcessing(detached.unparsedData); |
582 } | 582 } |
583 } | 583 } |
584 | 584 |
585 | 585 |
586 class _WebSocketHandler implements WebSocketHandler { | 586 class _WebSocketHandler implements WebSocketHandler { |
587 void onRequest(HttpRequest request, HttpResponse response) { | 587 void onRequest(HttpRequest request, HttpResponse response) { |
588 // Check that this is a web socket upgrade. | 588 // Check that this is a web socket upgrade. |
589 if (!_isWebSocketUpgrade(request)) { | 589 if (!_isWebSocketUpgrade(request)) { |
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
864 | 864 |
865 class _WebSocketCloseEvent implements CloseEvent { | 865 class _WebSocketCloseEvent implements CloseEvent { |
866 _WebSocketCloseEvent(this._wasClean, this._code, this._reason); | 866 _WebSocketCloseEvent(this._wasClean, this._code, this._reason); |
867 bool get wasClean => _wasClean; | 867 bool get wasClean => _wasClean; |
868 int get code => _code; | 868 int get code => _code; |
869 String get reason => _reason; | 869 String get reason => _reason; |
870 bool _wasClean; | 870 bool _wasClean; |
871 int _code; | 871 int _code; |
872 String _reason; | 872 String _reason; |
873 } | 873 } |
OLD | NEW |