commit | d50ac26d01675b0af5f20547b4bd60154cc6936a | [log] [tgz] |
---|---|---|
author | Keerti Parthasarathy <keertip@users.noreply.github.com> | Fri Sep 29 08:31:09 2017 -0700 |
committer | GitHub <noreply@github.com> | Fri Sep 29 08:31:09 2017 -0700 |
tree | a3f12ee438e82db6a026344e094e357c7725487f | |
parent | c87aa8a750056756d7437dd0a3faa4ecf16921bc [diff] |
Make package strong, also add analysis options file (#4) * Make package strong, also add analysis options file * Update analysis_options.yaml * Update web_socket_handler.dart * Update pubspec.yaml * Update web_socket_handler.dart
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.
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}'); }); }