commit | dedd6040d45159bd0661eb5252c7e936d6b7514a | [log] [tgz] |
---|---|---|
author | Kevin Moore <kevmoo@users.noreply.github.com> | Thu Feb 18 14:02:45 2021 -0800 |
committer | GitHub <noreply@github.com> | Thu Feb 18 14:02:45 2021 -0800 |
tree | 964a9435535f5b0870005da5e2eb37084976d625 | |
parent | b288e4e5c282d795fd3759143034be3fe9d86bd3 [diff] |
Support the latest pkg:web_socket_channel (#30) Also allow latest pkg:http as dev_dependency
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}'); }); }