chore: set max SDK version to <3.0.0 (#10)
5 files changed
tree: f4e5b2cc47e26ba4c161aa3257a2af4ee02c3196
- lib/
- test/
- .gitignore
- .test_config
- .travis.yml
- CHANGELOG.md
- codereview.settings
- LICENSE
- pubspec.yaml
- 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}');
});
}