commit | 24fb8a04befa75a94ac63a27047b231d1a22aab4 | [log] [tgz] |
---|---|---|
author | Jacob MacDonald <jakemac@google.com> | Wed Mar 17 19:51:29 2021 |
committer | GitHub <noreply@github.com> | Wed Mar 17 19:51:29 2021 |
tree | 69a4ae077bf09b7c1ee5f948719ac3516ae44d4d | |
parent | aa312d3cdeef96fb64bc3e602bc354a05a995624 [diff] |
release 1.0.1 (#35)
shelf_web_socket
is a Shelf handler for establishing WebSocket connections. It exposes a single function, webSocketHandler, which calls an onConnection
callback with a WebSocketChannel object for every connection that's established.
import 'package:shelf/shelf_io.dart' as shelf_io; import 'package:shelf_web_socket/shelf_web_socket.dart'; import 'package:web_socket_channel/web_socket_channel.dart'; void main() { var handler = webSocketHandler((webSocket) { webSocket.stream.listen((message) { webSocket.sink.add("echo $message"); }); }); shelf_io.serve(handler, 'localhost', 8080).then((server) { print('Serving at ws://${server.address.host}:${server.port}'); }); }