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 part of dart.io; | 5 part of dart.io; |
6 | 6 |
7 /** | 7 /** |
8 * The [SecureServerSocket] is a server socket, providing a stream of high-level | 8 * The [SecureServerSocket] is a server socket, providing a stream of high-level |
9 * [Socket]s. | 9 * [Socket]s. |
10 * | 10 * |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 port, | 72 port, |
73 certificateName, | 73 certificateName, |
74 backlog: backlog, | 74 backlog: backlog, |
75 v6Only: v6Only, | 75 v6Only: v6Only, |
76 requestClientCertificate: requestClientCertificate, | 76 requestClientCertificate: requestClientCertificate, |
77 requireClientCertificate: requireClientCertificate).then( | 77 requireClientCertificate: requireClientCertificate).then( |
78 (serverSocket) => new SecureServerSocket._(serverSocket)); | 78 (serverSocket) => new SecureServerSocket._(serverSocket)); |
79 } | 79 } |
80 | 80 |
81 StreamSubscription<SecureSocket> listen(void onData(SecureSocket socket), | 81 StreamSubscription<SecureSocket> listen(void onData(SecureSocket socket), |
82 {void onError(error), | 82 {Function onError, |
83 void onDone(), | 83 void onDone(), |
84 bool cancelOnError}) { | 84 bool cancelOnError}) { |
85 return _socket.map((rawSocket) => new SecureSocket._(rawSocket)) | 85 return _socket.map((rawSocket) => new SecureSocket._(rawSocket)) |
86 .listen(onData, | 86 .listen(onData, |
87 onError: onError, | 87 onError: onError, |
88 onDone: onDone, | 88 onDone: onDone, |
89 cancelOnError: cancelOnError); | 89 cancelOnError: cancelOnError); |
90 } | 90 } |
91 | 91 |
92 /** | 92 /** |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
183 bool requireClientCertificate: false}) { | 183 bool requireClientCertificate: false}) { |
184 return RawServerSocket.bind(address, port, backlog: backlog, v6Only: v6Only) | 184 return RawServerSocket.bind(address, port, backlog: backlog, v6Only: v6Only) |
185 .then((serverSocket) => new RawSecureServerSocket._( | 185 .then((serverSocket) => new RawSecureServerSocket._( |
186 serverSocket, | 186 serverSocket, |
187 certificateName, | 187 certificateName, |
188 requestClientCertificate, | 188 requestClientCertificate, |
189 requireClientCertificate)); | 189 requireClientCertificate)); |
190 } | 190 } |
191 | 191 |
192 StreamSubscription<RawSecureSocket> listen(void onData(RawSecureSocket s), | 192 StreamSubscription<RawSecureSocket> listen(void onData(RawSecureSocket s), |
193 {void onError(error), | 193 {Function onError, |
194 void onDone(), | 194 void onDone(), |
195 bool cancelOnError}) { | 195 bool cancelOnError}) { |
196 return _controller.stream.listen(onData, | 196 return _controller.stream.listen(onData, |
197 onError: onError, | 197 onError: onError, |
198 onDone: onDone, | 198 onDone: onDone, |
199 cancelOnError: cancelOnError); | 199 cancelOnError: cancelOnError); |
200 } | 200 } |
201 | 201 |
202 /** | 202 /** |
203 * Returns the port used by this socket. | 203 * Returns the port used by this socket. |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
236 } else { | 236 } else { |
237 _controller.add(secureConnection); | 237 _controller.add(secureConnection); |
238 } | 238 } |
239 }).catchError((e) { | 239 }).catchError((e) { |
240 if (!_closed) { | 240 if (!_closed) { |
241 _controller.addError(e); | 241 _controller.addError(e); |
242 } | 242 } |
243 }); | 243 }); |
244 } | 244 } |
245 | 245 |
246 void _onError(e) { | 246 void _onError(e, [StackTrace stackTrace]) { |
247 _controller.addError(e); | 247 _controller.addError(e, stackTrace); |
248 } | 248 } |
249 | 249 |
250 void _onDone() { | 250 void _onDone() { |
251 _controller.close(); | 251 _controller.close(); |
252 } | 252 } |
253 | 253 |
254 void _onPauseStateChange() { | 254 void _onPauseStateChange() { |
255 if (_controller.isPaused) { | 255 if (_controller.isPaused) { |
256 _subscription.pause(); | 256 _subscription.pause(); |
257 } else { | 257 } else { |
258 _subscription.resume(); | 258 _subscription.resume(); |
259 } | 259 } |
260 } | 260 } |
261 | 261 |
262 void _onSubscriptionStateChange() { | 262 void _onSubscriptionStateChange() { |
263 if (_controller.hasListener) { | 263 if (_controller.hasListener) { |
264 _subscription = _socket.listen(_onData, | 264 _subscription = _socket.listen(_onData, |
265 onDone: _onDone, | 265 onDone: _onDone, |
266 onError: _onError); | 266 onError: _onError); |
267 } else { | 267 } else { |
268 close(); | 268 close(); |
269 } | 269 } |
270 } | 270 } |
271 } | 271 } |
272 | 272 |
273 | 273 |
OLD | NEW |