Compatiblity with shelf 0.5.0.
Mark as compatible with shelf 0.6.0.

R=kevmoo@google.com
BUG=

Review URL: https://codereview.chromium.org//964543003
2 files changed
tree: 5369e1dacee2bcc846f79b120920bbfe53b284c9
  1. lib/
  2. test/
  3. .gitignore
  4. .status
  5. CHANGELOG.md
  6. codereview.settings
  7. LICENSE
  8. pubspec.yaml
  9. README.md
README.md

Web Socket Handler for Shelf

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}');
  });
}