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

Unified Diff: sdk/lib/io/websocket.dart

Issue 91223002: Add support for Websocket protocols. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 1 month 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 side-by-side diff with in-line comments
Download patch
Index: sdk/lib/io/websocket.dart
diff --git a/sdk/lib/io/websocket.dart b/sdk/lib/io/websocket.dart
index a3f2b258e4d97fbf4e845491832d583ef7d9118f..f9229ae8e5afc6b9d32de18b27b0f5ddafc1b10f 100644
--- a/sdk/lib/io/websocket.dart
+++ b/sdk/lib/io/websocket.dart
@@ -53,7 +53,9 @@ abstract class WebSocketStatus {
*/
abstract class WebSocketTransformer
implements StreamTransformer<HttpRequest, WebSocket> {
- factory WebSocketTransformer() => new _WebSocketTransformerImpl();
+
+ factory WebSocketTransformer({protocolSelector(List<String> protocols)})
+ => new _WebSocketTransformerImpl(protocolSelector);
/**
* Upgrades a [HttpRequest] to a [WebSocket] connection. If the
@@ -62,8 +64,9 @@ abstract class WebSocketTransformer
* future will complete with the [WebSocket] when the upgrade pocess
* is complete.
*/
- static Future<WebSocket> upgrade(HttpRequest request) {
- return _WebSocketTransformerImpl._upgrade(request);
+ static Future<WebSocket> upgrade(HttpRequest request,
+ {protocolSelector(List<String> protocols)}) {
+ return _WebSocketTransformerImpl._upgrade(request, protocolSelector);
}
/**
@@ -92,11 +95,11 @@ abstract class WebSocket implements Stream, StreamSink {
/**
* Create a new web socket connection. The URL supplied in [url]
- * must use the scheme [:ws:] or [:wss:]. The [protocols] argument is either
- * a [:String:] or [:List<String>:] specifying the subprotocols the
- * client is willing to speak.
+ * must use the scheme [:ws:] or [:wss:]. The [protocols] argument is
+ * specifying the subprotocols the client is willing to speak.
*/
- static Future<WebSocket> connect(String url, [protocols]) =>
+ static Future<WebSocket> connect(String url,
+ {List<String> protocols: const []}) =>
_WebSocketImpl.connect(url, protocols);
/**

Powered by Google App Engine
This is Rietveld 408576698