Stop using comment-based generics.
Stop using comment-based generic syntax (#3)

Closes #2
3 files changed
tree: 5427b4876913f9dc70de685149be4d1cb2f5379b
  1. .gitignore
  2. .test_config
  3. CHANGELOG.md
  4. LICENSE
  5. README.md
  6. codereview.settings
  7. lib/
  8. pubspec.yaml
  9. test/
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}');
  });
}