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

Side by Side 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, 9 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
« no previous file with comments | « no previous file | lib/html.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 The `web_socket_channel` package provides [`StreamChannel`][stream_channel] 1 The `web_socket_channel` package provides [`StreamChannel`][stream_channel]
2 wrappers for WebSocket connections. It provides a cross-platform 2 wrappers for WebSocket connections. It provides a cross-platform
3 [`WebSocketChannel`][WebSocketChannel] API, a cross-platform implementation of 3 [`WebSocketChannel`][WebSocketChannel] API, a cross-platform implementation of
4 that API that communicates over an underlying [`StreamChannel`][stream_channel], 4 that API that communicates over an underlying [`StreamChannel`][stream_channel],
5 and [an implementation][IOWebSocketChannel] that wraps `dart:io`'s `WebSocket` 5 [an implementation][IOWebSocketChannel] that wraps `dart:io`'s `WebSocket`
6 class. 6 class, and [a similar implementation][HtmlWebSocketChannel] that wrap's
7 `dart:html`'s.
7 8
8 [stream_channel]: https://pub.dartlang.org/packages/stream_channel 9 [stream_channel]: https://pub.dartlang.org/packages/stream_channel
9 [WebSocketChannel]: https://www.dartdocs.org/documentation/web_socket_channel/la test/web_socket_channel/WebSocketChannel-class.html 10 [WebSocketChannel]: https://www.dartdocs.org/documentation/web_socket_channel/la test/web_socket_channel/WebSocketChannel-class.html
10 [IOWebSocketChannel]: https://www.dartdocs.org/documentation/web_socket_channel/ latest/io/IOWebSocketChannel-class.html 11 [IOWebSocketChannel]: https://www.dartdocs.org/documentation/web_socket_channel/ latest/io/IOWebSocketChannel-class.html
12 [HtmlWebSocketChannel]: https://www.dartdocs.org/documentation/web_socket_channe l/latest/html/HtmlWebSocketChannel-class.html
11 13
12 ## `WebSocketChannel` 14 ## `WebSocketChannel`
13 15
14 The [`WebSocketChannel`][WebSocketChannel] class's most important role is as the 16 The [`WebSocketChannel`][WebSocketChannel] class's most important role is as the
15 interface for WebSocket stream channels across all implementations and all 17 interface for WebSocket stream channels across all implementations and all
16 platforms. In addition to the base `StreamChannel` interface, it adds a 18 platforms. In addition to the base `StreamChannel` interface, it adds a
17 [`protocol`][protocol] getter that returns the negotiated protocol for the 19 [`protocol`][protocol] getter that returns the negotiated protocol for the
18 socket, as well as [`closeCode`][closeCode] and [`closeReason`][closeReason] 20 socket, as well as [`closeCode`][closeCode] and [`closeReason`][closeReason]
19 getters that provide information about why the socket closed. 21 getters that provide information about why the socket closed.
20 22
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 import 'package:web_socket_channel/io.dart'; 69 import 'package:web_socket_channel/io.dart';
68 70
69 main() async { 71 main() async {
70 var channel = new IOWebSocketChannel.connect("ws://localhost:8181"); 72 var channel = new IOWebSocketChannel.connect("ws://localhost:8181");
71 channel.sink.add("connected!"); 73 channel.sink.add("connected!");
72 channel.sink.listen((message) { 74 channel.sink.listen((message) {
73 // ... 75 // ...
74 }); 76 });
75 } 77 }
76 ``` 78 ```
79
80 ## `HtmlWebSocketChannel`
81
82 The [`HtmlWebSocketChannel`][HtmlWebSocketChannel] class wraps
83 [`dart:html`'s `WebSocket` class][html.WebSocket]. Because it imports
84 `dart:html`, it has its own library, `package:web_socket_channel/html.dart`.
85 This allows the main `WebSocketChannel` class to be available on all platforms.
86
87 [html.WebSocket]: https://api.dartlang.org/latest/dart-html/WebSocket-class.html
88
89 An `HtmlWebSocketChannel` can be created by passing a `dart:html` WebSocket to
90 [its constructor][new HtmlWebSocketChannel]. It's more common to want to connect
91 directly to a `ws://` or `wss://` URL, in which case
92 [`new HtmlWebSocketChannel.connect()`][HtmlWebSocketChannel.connect] should be u sed.
93
94 [new HtmlWebSocketChannel]: https://www.dartdocs.org/documentation/web_socket_ch annel/latest/html/HtmlWebSocketChannel/HtmlWebSocketChannel.html
95 [HtmlWebSocketChannel.connect]: https://www.dartdocs.org/documentation/web_socke t_channel/latest/html/HtmlWebSocketChannel/HtmlWebSocketChannel.connect.html
96
97 ```dart
98 import 'package:web_socket_channel/html.dart';
99
100 main() async {
101 var channel = new HtmlWebSocketChannel.connect("ws://localhost:8181");
102 channel.sink.add("connected!");
103 channel.sink.listen((message) {
104 // ...
105 });
106 }
107 ```
OLDNEW
« 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