Add optional protocols argument to WebSocketChannel.connect (dart-lang/web_socket_channel#97)
Forwarded to the `WebSocket` constructors.
diff --git a/pkgs/web_socket_channel/lib/src/_connect_api.dart b/pkgs/web_socket_channel/lib/src/_connect_api.dart
index 93c6ce7..b9fe0b4 100644
--- a/pkgs/web_socket_channel/lib/src/_connect_api.dart
+++ b/pkgs/web_socket_channel/lib/src/_connect_api.dart
@@ -8,6 +8,8 @@
///
/// Connects to [uri] using and returns a channel that can be used to
/// communicate over the resulting socket.
-WebSocketChannel connect(Uri uri) {
+///
+/// The optional [protocols] parameter is the same as [WebSocket.connect].
+WebSocketChannel connect(Uri uri, {Iterable<String> protocols}) {
throw UnsupportedError('No implementation of the connect api provided');
}
diff --git a/pkgs/web_socket_channel/lib/src/_connect_html.dart b/pkgs/web_socket_channel/lib/src/_connect_html.dart
index 3c36641..895b7b2 100644
--- a/pkgs/web_socket_channel/lib/src/_connect_html.dart
+++ b/pkgs/web_socket_channel/lib/src/_connect_html.dart
@@ -10,4 +10,7 @@
///
/// Connects to [uri] using and returns a channel that can be used to
/// communicate over the resulting socket.
-WebSocketChannel connect(Uri uri) => HtmlWebSocketChannel.connect(uri);
+///
+/// The optional [protocols] parameter is the same as [WebSocket.connect].
+WebSocketChannel connect(Uri uri, {Iterable<String> protocols}) =>
+ HtmlWebSocketChannel.connect(uri, protocols: protocols);
diff --git a/pkgs/web_socket_channel/lib/src/_connect_io.dart b/pkgs/web_socket_channel/lib/src/_connect_io.dart
index b788926..60f02c4 100644
--- a/pkgs/web_socket_channel/lib/src/_connect_io.dart
+++ b/pkgs/web_socket_channel/lib/src/_connect_io.dart
@@ -8,5 +8,8 @@
/// Creates a new WebSocket connection.
///
/// Connects to [uri] using and returns a channel that can be used to
-/// communicate over the resulting socket
-WebSocketChannel connect(Uri uri) => IOWebSocketChannel.connect(uri);
+/// communicate over the resulting socket.
+///
+/// The optional [protocols] parameter is the same as [WebSocket.connect].
+WebSocketChannel connect(Uri uri, {Iterable<String> protocols}) =>
+ IOWebSocketChannel.connect(uri, protocols: protocols);
diff --git a/pkgs/web_socket_channel/lib/src/channel.dart b/pkgs/web_socket_channel/lib/src/channel.dart
index 8fcee55..c2c13e2 100644
--- a/pkgs/web_socket_channel/lib/src/channel.dart
+++ b/pkgs/web_socket_channel/lib/src/channel.dart
@@ -105,7 +105,10 @@
///
/// Connects to [uri] using and returns a channel that can be used to
/// communicate over the resulting socket.
- factory WebSocketChannel.connect(Uri uri) => platform.connect(uri);
+ ///
+ /// The optional [protocols] parameter is the same as [WebSocket.connect].
+ factory WebSocketChannel.connect(Uri uri, {Iterable<String> protocols}) =>
+ platform.connect(uri, protocols: protocols);
}
/// The sink exposed by a [WebSocketChannel].