commit | 141f5770f82cd99762c080d6c017f5fff048efd8 | [log] [tgz] |
---|---|---|
author | Max Wagner <33731918+emeyex@users.noreply.github.com> | Wed Apr 17 19:28:19 2019 |
committer | Nate Bosch <nbosch1@gmail.com> | Wed Apr 17 19:28:19 2019 |
tree | 7931ce1d7417e6aca1daff342300154f65421bca | |
parent | 8f2ad430e8d8129c8b4e7d46495a818012f5b6ef [diff] |
Add `pingInterval` pass through param (#16) Configures the construction of the WebSocketChannel.
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}'); }); }