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

Side by Side Diff: sdk/lib/io/websocket.dart

Issue 14208007: Improve WebSocket interface by making it implement StreamSink. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 8 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
OLDNEW
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 part of dart.io; 5 part of dart.io;
6 6
7 /** 7 /**
8 * Web socket status codes used when closing a web socket connection. 8 * Web socket status codes used when closing a web socket connection.
9 */ 9 */
10 abstract class WebSocketStatus { 10 abstract class WebSocketStatus {
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 return _WebSocketTransformerImpl._isUpgradeRequest(request); 73 return _WebSocketTransformerImpl._isUpgradeRequest(request);
74 } 74 }
75 } 75 }
76 76
77 77
78 /** 78 /**
79 * A client or server web socket connection. The stream exposes the 79 * A client or server web socket connection. The stream exposes the
80 * messages received. A text message will be of type [:String:] and a 80 * messages received. A text message will be of type [:String:] and a
81 * binary message will be of type [:List<int>:]. 81 * binary message will be of type [:List<int>:].
82 */ 82 */
83 abstract class WebSocket implements Stream { 83 abstract class WebSocket implements Stream, StreamSink {
84 /** 84 /**
85 * Possible states of the connection. 85 * Possible states of the connection.
86 */ 86 */
87 static const int CONNECTING = 0; 87 static const int CONNECTING = 0;
88 static const int OPEN = 1; 88 static const int OPEN = 1;
89 static const int CLOSING = 2; 89 static const int CLOSING = 2;
90 static const int CLOSED = 3; 90 static const int CLOSED = 3;
91 91
92 /** 92 /**
93 * Create a new web socket connection. The URL supplied in [url] 93 * Create a new web socket connection. The URL supplied in [url]
(...skipping 30 matching lines...) Expand all
124 */ 124 */
125 int get closeCode; 125 int get closeCode;
126 126
127 /** 127 /**
128 * The close reason set when the web socket connection is closed. If 128 * The close reason set when the web socket connection is closed. If
129 * there is no close reason available this property will be [:null:] 129 * there is no close reason available this property will be [:null:]
130 */ 130 */
131 String get closeReason; 131 String get closeReason;
132 132
133 /** 133 /**
134 * Closes the web socket connection. 134 * Closes the web socket connection.
Søren Gjesse 2013/04/16 12:41:31 Please add documentation on the default values. It
Anders Johnsen 2013/04/16 13:46:22 Done.
135 */ 135 */
136 void close([int code, String reason]); 136 Future close([int code, String reason]);
137 137
138 /** 138 /**
139 * Sends data on the web socket connection. The data in [data] must 139 * Sends data on the web socket connection. The data in [data] must
140 * be either a [:String:], or a [:List<int>:] holding bytes. 140 * be either a [:String:], or a [:List<int>:] holding bytes.
141 */ 141 */
142 void send(data); 142 void add(data);
Søren Gjesse 2013/04/16 12:41:31 We should add addStream with some dartdoc here as
Anders Johnsen 2013/04/16 13:46:22 addError will more or less just close the connecti
143 } 143 }
144 144
145 145
146 class WebSocketException implements Exception { 146 class WebSocketException implements Exception {
147 const WebSocketException([String this.message = ""]); 147 const WebSocketException([String this.message = ""]);
148 String toString() => "WebSocketException: $message"; 148 String toString() => "WebSocketException: $message";
149 final String message; 149 final String message;
150 } 150 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698