Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(471)

Side by Side Diff: runtime/bin/websocket_impl.dart

Issue 10351009: Implement onClosed on a socket output stream (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « runtime/bin/socket_stream_impl.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 final String _webSocketGUID = "258EAFA5-E914-47DA-95CA-C5AB0DC85B11"; 5 final String _webSocketGUID = "258EAFA5-E914-47DA-95CA-C5AB0DC85B11";
6 6
7 class _WebSocketMessageType { 7 class _WebSocketMessageType {
8 static final int NONE = 0; 8 static final int NONE = 0;
9 static final int BINARY = 1; 9 static final int BINARY = 1;
10 static final int TEXT = 2; 10 static final int TEXT = 2;
(...skipping 415 matching lines...) Expand 10 before | Expand all | Expand 10 after
426 if (reason != null) { 426 if (reason != null) {
427 data.addAll( 427 data.addAll(
428 _StringEncoders.encoder(Encoding.UTF_8).encodeString(reason)); 428 _StringEncoders.encoder(Encoding.UTF_8).encodeString(reason));
429 } 429 }
430 } 430 }
431 _sendFrame(_WebSocketOpcode.CLOSE, data); 431 _sendFrame(_WebSocketOpcode.CLOSE, data);
432 432
433 if (_closeReceived) { 433 if (_closeReceived) {
434 // Close the socket when the close frame has been sent - if it 434 // Close the socket when the close frame has been sent - if it
435 // does not take too long. 435 // does not take too long.
436 _socket.close(true); 436 _socket.outputStream.close();
437 _socket.outputStream.onNoPendingWrites = () { 437 _socket.outputStream.onClosed = () {
438 if (_closeTimer != null) _closeTimer.cancel(); 438 if (_closeTimer != null) _closeTimer.cancel();
439 _socket.close(); 439 _socket.close();
440 }; 440 };
441 _closeTimer = new Timer(5000, (t) { 441 _closeTimer = new Timer(5000, (t) {
442 _socket.close(); 442 _socket.close();
443 }); 443 });
444 } else { 444 } else {
445 // Half close the socket and expect a close frame in response 445 // Half close the socket and expect a close frame in response
446 // before closing the socket. If a close frame does not arrive 446 // before closing the socket. If a close frame does not arrive
447 // within a reasonable amount of time just close the socket. 447 // within a reasonable amount of time just close the socket.
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after
726 } 726 }
727 return true; 727 return true;
728 } 728 }
729 729
730 Function _onRequest; 730 Function _onRequest;
731 Function _onOpen; 731 Function _onOpen;
732 Function _onNoUpgrade; 732 Function _onNoUpgrade;
733 HttpClientConnection _conn; 733 HttpClientConnection _conn;
734 String _nonce; 734 String _nonce;
735 } 735 }
OLDNEW
« no previous file with comments | « runtime/bin/socket_stream_impl.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698