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

Unified Diff: pkg/shelf_web_socket/README.md

Issue 297593003: Add a shelf_web_socket package. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: fixes Created 6 years, 7 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 | « pkg/shelf_web_socket/LICENSE ('k') | pkg/shelf_web_socket/lib/shelf_web_socket.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/shelf_web_socket/README.md
diff --git a/pkg/shelf_web_socket/README.md b/pkg/shelf_web_socket/README.md
new file mode 100644
index 0000000000000000000000000000000000000000..9091de0f7d352eb99f3f720fc335a94cc24854c6
--- /dev/null
+++ b/pkg/shelf_web_socket/README.md
@@ -0,0 +1,31 @@
+## Web Socket Handler for Shelf
+
+`shelf_web_socket` is a [Shelf][] handler for establishing [WebSocket][]
+connections. It exposes a single function, [webSocketHandler][], which calls an
+`onConnection` callback with a [CompatibleWebSocket][] object for every
+connection that's established.
+
+[Shelf]: pub.dartlang.org/packages/shelf
+
+[WebSocket]: https://tools.ietf.org/html/rfc6455
+
+[webSocketHandler]: https://api.dartlang.org/apidocs/channels/be/dartdoc-viewer/shelf_web_socket/shelf_web_socket.webSocketHandler
+
+[CompatibleWebSocket]: https://api.dartlang.org/apidocs/channels/be/dartdoc-viewer/http_parser/http_parser.CompatibleWebSocket
+
+```dart
+import 'package:shelf/shelf_io.dart' as shelf_io;
+import 'package:shelf_web_socket/shelf_web_socket.dart';
+
+void main() {
+ var handler = webSocketHandler((webSocket) {
+ webSocket.listen((message) {
+ webSocket.add("echo $message");
+ });
+ });
+
+ shelf_io.serve(handler, 'localhost', 8080).then((server) {
+ print('Serving at ws://${server.address.host}:${server.port}');
+ });
+}
+```
« no previous file with comments | « pkg/shelf_web_socket/LICENSE ('k') | pkg/shelf_web_socket/lib/shelf_web_socket.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698