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

Side by Side Diff: README.md

Issue 1758053002: Add a top-level status library. (Closed) Base URL: git@github.com:dart-lang/web_socket_channel.git@master
Patch Set: 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/status.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 [an implementation][IOWebSocketChannel] that wraps `dart:io`'s `WebSocket` 5 [an implementation][IOWebSocketChannel] that wraps `dart:io`'s `WebSocket`
6 class, and [a similar implementation][HtmlWebSocketChannel] that wrap's 6 class, and [a similar implementation][HtmlWebSocketChannel] that wrap's
7 `dart:html`'s. 7 `dart:html`'s.
8 8
9 [stream_channel]: https://pub.dartlang.org/packages/stream_channel 9 [stream_channel]: https://pub.dartlang.org/packages/stream_channel
10 [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
11 [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 12 [HtmlWebSocketChannel]: https://www.dartdocs.org/documentation/web_socket_channe l/latest/html/HtmlWebSocketChannel-class.html
13 13
14 It also provides constants for the WebSocket protocol's pre-defined status codes
15 in the [`status.dart` library][status]. It's strongly recommended that users
16 import this library should be imported with the prefix `status`.
17
18 [status]: https://www.dartdocs.org/documentation/web_socket_channel/latest/statu s/status-library.html
19
20 ```dart
21 import 'package:web_socket_channel/io.dart';
22 import 'package:web_socket_channel/status.dart' as status;
23
24 main() async {
25 var channel = await IOWebSocketChannel.connect("ws://localhost:1234");
26
27 channel.stream.listen((message) {
28 channel.sink.add("received!");
29 channel.close(status.goingAway);
30 });
31 }
32 ```
33
14 ## `WebSocketChannel` 34 ## `WebSocketChannel`
15 35
16 The [`WebSocketChannel`][WebSocketChannel] class's most important role is as the 36 The [`WebSocketChannel`][WebSocketChannel] class's most important role is as the
17 interface for WebSocket stream channels across all implementations and all 37 interface for WebSocket stream channels across all implementations and all
18 platforms. In addition to the base `StreamChannel` interface, it adds a 38 platforms. In addition to the base `StreamChannel` interface, it adds a
19 [`protocol`][protocol] getter that returns the negotiated protocol for the 39 [`protocol`][protocol] getter that returns the negotiated protocol for the
20 socket, as well as [`closeCode`][closeCode] and [`closeReason`][closeReason] 40 socket, as well as [`closeCode`][closeCode] and [`closeReason`][closeReason]
21 getters that provide information about why the socket closed. 41 getters that provide information about why the socket closed.
22 42
23 [protocol]: https://www.dartdocs.org/documentation/web_socket_channel/latest/web _socket_channel/WebSocketChannel/protocol.html 43 [protocol]: https://www.dartdocs.org/documentation/web_socket_channel/latest/web _socket_channel/WebSocketChannel/protocol.html
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 import 'package:web_socket_channel/html.dart'; 118 import 'package:web_socket_channel/html.dart';
99 119
100 main() async { 120 main() async {
101 var channel = new HtmlWebSocketChannel.connect("ws://localhost:8181"); 121 var channel = new HtmlWebSocketChannel.connect("ws://localhost:8181");
102 channel.sink.add("connected!"); 122 channel.sink.add("connected!");
103 channel.sink.listen((message) { 123 channel.sink.listen((message) {
104 // ... 124 // ...
105 }); 125 });
106 } 126 }
107 ``` 127 ```
OLDNEW
« no previous file with comments | « no previous file | lib/status.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698