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 patch class RawServerSocket { | 5 patch class RawServerSocket { |
6 /* patch */ static Future<RawServerSocket> bind([String address = "127.0.0.1", | 6 /* patch */ static Future<RawServerSocket> bind([String address = "127.0.0.1", |
7 int port = 0, | 7 int port = 0, |
8 int backlog = 0]) { | 8 int backlog = 0]) { |
9 return _RawServerSocket.bind(address, port, backlog); | 9 return _RawServerSocket.bind(address, port, backlog); |
10 } | 10 } |
(...skipping 416 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
427 _controller = new StreamController( | 427 _controller = new StreamController( |
428 onSubscriptionStateChange: _onSubscriptionStateChange, | 428 onSubscriptionStateChange: _onSubscriptionStateChange, |
429 onPauseStateChange: _onPauseStateChange); | 429 onPauseStateChange: _onPauseStateChange); |
430 _socket.closeFuture.then((_) => _controller.close()); | 430 _socket.closeFuture.then((_) => _controller.close()); |
431 _socket.setHandlers( | 431 _socket.setHandlers( |
432 read: () { | 432 read: () { |
433 var socket = _socket.accept(); | 433 var socket = _socket.accept(); |
434 if (socket != null) _controller.add(new _RawSocket(socket)); | 434 if (socket != null) _controller.add(new _RawSocket(socket)); |
435 }, | 435 }, |
436 error: (e) { | 436 error: (e) { |
437 _controller.signalError(new AsyncError(e)); | 437 _controller.addError(new AsyncError(e)); |
438 _controller.close(); | 438 _controller.close(); |
439 } | 439 } |
440 ); | 440 ); |
441 } | 441 } |
442 | 442 |
443 StreamSubscription<RawSocket> listen(void onData(RawSocket event), | 443 StreamSubscription<RawSocket> listen(void onData(RawSocket event), |
444 {void onError(AsyncError error), | 444 {void onError(AsyncError error), |
445 void onDone(), | 445 void onDone(), |
446 bool unsubscribeOnError}) { | 446 bool unsubscribeOnError}) { |
447 return _controller.stream.listen( | 447 return _controller.stream.listen( |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
500 _socket.setHandlers( | 500 _socket.setHandlers( |
501 read: () => _controller.add(RawSocketEvent.READ), | 501 read: () => _controller.add(RawSocketEvent.READ), |
502 write: () { | 502 write: () { |
503 // The write event handler is automatically disabled by the | 503 // The write event handler is automatically disabled by the |
504 // event handler when it fires. | 504 // event handler when it fires. |
505 _writeEventsEnabled = false; | 505 _writeEventsEnabled = false; |
506 _controller.add(RawSocketEvent.WRITE); | 506 _controller.add(RawSocketEvent.WRITE); |
507 }, | 507 }, |
508 closed: () => _controller.add(RawSocketEvent.READ_CLOSED), | 508 closed: () => _controller.add(RawSocketEvent.READ_CLOSED), |
509 error: (e) { | 509 error: (e) { |
510 _controller.signalError(new AsyncError(e)); | 510 _controller.addError(new AsyncError(e)); |
511 close(); | 511 close(); |
512 } | 512 } |
513 ); | 513 ); |
514 } | 514 } |
515 | 515 |
516 factory _RawSocket._writePipe(int fd) { | 516 factory _RawSocket._writePipe(int fd) { |
517 var native = new _NativeSocket.pipe(); | 517 var native = new _NativeSocket.pipe(); |
518 native.isClosedRead = true; | 518 native.isClosedRead = true; |
519 if (fd != null) _getStdioHandle(native, fd); | 519 if (fd != null) _getStdioHandle(native, fd); |
520 return new _RawSocket(native); | 520 return new _RawSocket(native); |
(...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
856 if (!_controllerClosed) { | 856 if (!_controllerClosed) { |
857 _controllerClosed = true; | 857 _controllerClosed = true; |
858 _controller.close(); | 858 _controller.close(); |
859 } | 859 } |
860 _done(); | 860 _done(); |
861 } | 861 } |
862 | 862 |
863 void _onError(error) { | 863 void _onError(error) { |
864 if (!_controllerClosed) { | 864 if (!_controllerClosed) { |
865 _controllerClosed = true; | 865 _controllerClosed = true; |
866 _controller.signalError(error); | 866 _controller.addError(error); |
867 _controller.close(); | 867 _controller.close(); |
868 } | 868 } |
869 _done(error); | 869 _done(error); |
870 } | 870 } |
871 | 871 |
872 get _doneFuture { | 872 get _doneFuture { |
873 if (_doneCompleter == null) { | 873 if (_doneCompleter == null) { |
874 _ensureRawSocketSubscription(); | 874 _ensureRawSocketSubscription(); |
875 _doneCompleter = new Completer(); | 875 _doneCompleter = new Completer(); |
876 } | 876 } |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
922 _raw.onBadCertificate = callback; | 922 _raw.onBadCertificate = callback; |
923 } | 923 } |
924 | 924 |
925 X509Certificate get peerCertificate { | 925 X509Certificate get peerCertificate { |
926 if (_raw == null) { | 926 if (_raw == null) { |
927 throw new StateError("peerCertificate called on destroyed SecureSocket"); | 927 throw new StateError("peerCertificate called on destroyed SecureSocket"); |
928 } | 928 } |
929 return _raw.peerCertificate; | 929 return _raw.peerCertificate; |
930 } | 930 } |
931 } | 931 } |
OLD | NEW |