Clone this repo:
  1. d50ac26 Make package strong, also add analysis options file (#4) by Keerti Parthasarathy · 4 weeks ago master
  2. c87aa8a Revert "Make package strong, also add analysis options file" by Keerti Parthasarathy · 4 weeks ago
  3. b38b9c5 Make package strong, also add analysis options file by Keerti Parthasarathy · 4 weeks ago
  4. e49a44d Stop using comment-based generic syntax (#3) by Natalie Weizenbaum · 4 weeks ago 0.2.2
  5. b8dde80 Fix all strong-mode warnings. by Natalie Weizenbaum · 1 year, 6 months ago 0.2.1

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