|
1 | | -TODO: Put a short description of the package here that helps potential users |
2 | | -know whether this package might be useful for them. |
| 1 | +[](https://pub.dev/packages/web_socket) |
| 2 | +[](https://pub.dev/packages/web_socket/publisher) |
| 3 | + |
| 4 | +Any easy-to-use library for communicating with WebSockets that has multiple |
| 5 | +implementations. |
| 6 | + |
| 7 | +## Using |
| 8 | + |
| 9 | +```dart |
| 10 | +import 'package:web_socket/io_web_socket.dart'; |
| 11 | +import 'package:web_socket/web_socket.dart'; |
| 12 | +
|
| 13 | +void main() async { |
| 14 | + final socket = |
| 15 | + await IOWebSocket.connect(Uri.parse('wss://ws.postman-echo.com/raw')); |
| 16 | +
|
| 17 | + socket.events.listen((e) async { |
| 18 | + switch (e) { |
| 19 | + case TextDataReceived(text: final text): |
| 20 | + print('Received Text: $text'); |
| 21 | + await socket.close(); |
| 22 | + case BinaryDataReceived(data: final data): |
| 23 | + print('Received Binary: $data'); |
| 24 | + case CloseReceived(code: final code, reason: final reason): |
| 25 | + print('Connection to server closed: $code [$reason]'); |
| 26 | + } |
| 27 | + }); |
| 28 | +
|
| 29 | + socket.sendText('Hello Dart WebSockets! 🎉'); |
| 30 | +} |
| 31 | +``` |
| 32 | + |
| 33 | +## Status: experimental |
| 34 | + |
| 35 | +**NOTE**: This package is currently experimental and published under the |
| 36 | +[labs.dart.dev](https://dart.dev/dart-team-packages) pub publisher in order to |
| 37 | +solicit feedback. |
| 38 | + |
| 39 | +For packages in the labs.dart.dev publisher we generally plan to either graduate |
| 40 | +the package into a supported publisher (dart.dev, tools.dart.dev) after a period |
| 41 | +of feedback and iteration, or discontinue the package. These packages have a |
| 42 | +much higher expected rate of API and breaking changes. |
| 43 | + |
| 44 | +Your feedback is valuable and will help us evolve this package. For general |
| 45 | +feedback, suggestions, and comments, please file an issue in the |
| 46 | +[bug tracker](https://github.com/dart-lang/http/issues). |
0 commit comments