commit | d2e757b0153606e58adb01d275a17bc0651207bc | [log] [tgz] |
---|---|---|
author | Jacob MacDonald <jakemac@google.com> | Wed Feb 24 18:19:49 2021 |
committer | GitHub <noreply@github.com> | Wed Feb 24 18:19:49 2021 |
tree | e293296879515d16be1c95f99a0aec553ab3c9cd | |
parent | a20c47fb34ad6578186349a7d159a86e43379d49 [diff] |
add regular test dev dep (#33)
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}'); }); }