shelf_web_socket
v3.0.0A shelf handler that wires up a listener for every connection.
Архив пакета: https://pubdev.letsnova.ru/api/archives/shelf_web_socket/3.0.0.tar.gz
Установка
dart pub add shelf_web_socketREADME
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 WebSocketChannel 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.stream.listen((message) {
webSocket.sink.add('echo $message');
});
});
shelf_io.serve(handler, 'localhost', 8080).then((server) {
print('Serving at ws://${server.address.host}:${server.port}');
});
}
История изменений
3.0.0
- BREAKING:: Change the signature of the
webSocketHandlermethod'sonConnectioncallback. Previously this took an untyped function with either one or two parameters. This now requires aConnectionCallback; a typedef taking two parameters. See also https://github.com/dart-lang/shelf/issues/457. - Add a API usage example.
- Require Dart
^3.5.0.
Note that most clients seeing analysis issues from the above breaking change can fix it by adding a second parameter to their callback. So, they would change this:
webSocketHandler((webSocket) {
webSocket.stream.listen((message) {
webSocket.sink.add('echo $message');
});
});
to this:
webSocketHandler((webSocket, _) {
webSocket.stream.listen((message) {
webSocket.sink.add('echo $message');
});
});
2.0.1
- Require Dart
^3.3.0.
2.0.0
- BREAKING:: Remove support for hijacking WebSocket requests that are not
being transported using
dart:ioSockets. - Require Dart
^3.0.0.
1.0.4
- Added package topics to the pubspec file.
1.0.3
- Require Dart
2.17. - Fix checking for binary callbacks with strong null safety.
1.0.2
- Require Dart
2.14. - Update the pubspec
repositoryfield.
1.0.1
- Require the latest shelf, remove dead code.
1.0.0
- Migrate to null safety.
0.2.4+1
- Support the latest
package:web_socket_channel.
0.2.4
- Support the latest shelf release (
1.x.x). - Require at least Dart 2.1
- Allow omitting
protocolsargument even if theonConnectioncallback takes a second argument.
0.2.3
- Add
pingIntervalargument towebSocketHandler, to be passed through to the created channel.
0.2.2+5
- Allow
stream_channelversion 2.x
0.2.2+4
- Fix the check for
onConnectionto check the number of arguments and not that the arguments aredynamic.
0.2.2+3
- Set max SDK version to
<3.0.0, and adjust other dependencies.
0.2.2+2
- Stopped using deprected
HTML_ESCAPEconstant name.
0.2.2+1
- Update SDK version to 2.0.0-dev.17.0.
0.2.2
- Stop using comment-based generic syntax.
0.2.1
- Fix all strong-mode warnings.
0.2.0
- Breaking change:
webSocketHandler()now uses theWebSocketChannelclass defined in theweb_socket_channelpackage, rather than the deprecated class defined inhttp_parser.
0.1.0
- Breaking change:
webSocketHandler()now passes aWebSocketChannelto theonConnection()callback, rather than a deprecatedCompatibleWebSocket.
0.0.1+5
- Support
http_parser2.0.0.
0.0.1+4
- Fix a link to
shelfin the README.
0.0.1+3
- Support
http_parser1.0.0.
0.0.1+2
- Mark as compatible with version
0.6.0ofshelf.
0.0.1+1
- Properly parse the
Connectionheader. This fixes an issue where Firefox was unable to connect.
