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

Unified Diff: README.md

Issue 1747113003: Add an HTML implementation of WebSocketChannel. (Closed) Base URL: git@github.com:dart-lang/web_socket_channel.git@master
Patch Set: Code review changes Created 4 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | lib/html.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: README.md
diff --git a/README.md b/README.md
index 7e39a7998ff672fe64d97399a7b25d10c1622c73..3e984aa875ac14e149f1b365db37605c8f0a69f1 100644
--- a/README.md
+++ b/README.md
@@ -2,12 +2,14 @@ The `web_socket_channel` package provides [`StreamChannel`][stream_channel]
wrappers for WebSocket connections. It provides a cross-platform
[`WebSocketChannel`][WebSocketChannel] API, a cross-platform implementation of
that API that communicates over an underlying [`StreamChannel`][stream_channel],
-and [an implementation][IOWebSocketChannel] that wraps `dart:io`'s `WebSocket`
-class.
+[an implementation][IOWebSocketChannel] that wraps `dart:io`'s `WebSocket`
+class, and [a similar implementation][HtmlWebSocketChannel] that wrap's
+`dart:html`'s.
[stream_channel]: https://pub.dartlang.org/packages/stream_channel
[WebSocketChannel]: https://www.dartdocs.org/documentation/web_socket_channel/latest/web_socket_channel/WebSocketChannel-class.html
[IOWebSocketChannel]: https://www.dartdocs.org/documentation/web_socket_channel/latest/io/IOWebSocketChannel-class.html
+[HtmlWebSocketChannel]: https://www.dartdocs.org/documentation/web_socket_channel/latest/html/HtmlWebSocketChannel-class.html
## `WebSocketChannel`
@@ -74,3 +76,32 @@ main() async {
});
}
```
+
+## `HtmlWebSocketChannel`
+
+The [`HtmlWebSocketChannel`][HtmlWebSocketChannel] class wraps
+[`dart:html`'s `WebSocket` class][html.WebSocket]. Because it imports
+`dart:html`, it has its own library, `package:web_socket_channel/html.dart`.
+This allows the main `WebSocketChannel` class to be available on all platforms.
+
+[html.WebSocket]: https://api.dartlang.org/latest/dart-html/WebSocket-class.html
+
+An `HtmlWebSocketChannel` can be created by passing a `dart:html` WebSocket to
+[its constructor][new HtmlWebSocketChannel]. It's more common to want to connect
+directly to a `ws://` or `wss://` URL, in which case
+[`new HtmlWebSocketChannel.connect()`][HtmlWebSocketChannel.connect] should be used.
+
+[new HtmlWebSocketChannel]: https://www.dartdocs.org/documentation/web_socket_channel/latest/html/HtmlWebSocketChannel/HtmlWebSocketChannel.html
+[HtmlWebSocketChannel.connect]: https://www.dartdocs.org/documentation/web_socket_channel/latest/html/HtmlWebSocketChannel/HtmlWebSocketChannel.connect.html
+
+```dart
+import 'package:web_socket_channel/html.dart';
+
+main() async {
+ var channel = new HtmlWebSocketChannel.connect("ws://localhost:8181");
+ channel.sink.add("connected!");
+ channel.sink.listen((message) {
+ // ...
+ });
+}
+```
« no previous file with comments | « no previous file | lib/html.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698