pub repository
mirror.p-hatan.irweb_socket
0.1.5Any easy-to-use library for communicating with WebSockets that has multiple implementations.
Readme
Any easy-to-use library for communicating with WebSockets that has multiple implementations.
Why another WebSocket package?
The goal of package:web_socket is to provide a simple, well-defined
WebSockets interface that has
consistent behavior across implementations.
package:web_socket_channel
is currently the most popular WebSocket package. It has
two implementations, one based on package:web and the other based on
dart:io WebSocket. But those implementations do not have consistent
behavior.
WebSocket
currently has three implementations (with more on the way) that
all pass the same set of
conformance tests:
Using
import 'package:web_socket/web_socket.dart';
void main() async {
final socket =
await WebSocket.connect(Uri.parse('wss://ws.postman-echo.com/raw'));
socket.events.listen((e) async {
switch (e) {
case TextDataReceived(text: final text):
print('Received Text: $text');
await socket.close();
case BinaryDataReceived(data: final data):
print('Received Binary: $data');
case CloseReceived(code: final code, reason: final reason):
print('Connection to server closed: $code [$reason]');
}
});
socket.sendText('Hello Dart WebSockets! ๐');
}
Status: experimental
NOTE: This package is currently experimental and published under the labs.dart.dev pub publisher in order to solicit feedback.
For packages in the labs.dart.dev publisher we generally plan to either graduate the package into a supported publisher (dart.dev, tools.dart.dev) after a period of feedback and iteration, or discontinue the package. These packages have a much higher expected rate of API and breaking changes.
Your feedback is valuable and will help us evolve this package. For general feedback, suggestions, and comments, please file an issue in the bug tracker.
Changelog
0.1.5
- Allow
1000as a close code.
0.1.4
- Add a
fakesfunction that returns a pair ofWebSockets useful in testing.
0.1.3
- Bring the behavior in line with the documentation by throwing
WebSocketConnectionClosedratherStateErrorwhen attempting to send data to or close an already closedWebSocket.
0.1.2
- Fix a
StateErrorinIOWebSocketwhen data is received from the peer after the connection has been closed locally.
0.1.1
- Add the ability to create a
package:web_socketWebSocketgiven adart:ioWebSocket.
0.1.0
- Basic functionality in place.
Installing
export PUB_HOSTED_URL=https://pub.mirror.p-hatan.ir
flutter pub add web_socketpubspec.yaml
name: web_socket
description: >-
Any easy-to-use library for communicating with WebSockets
that has multiple implementations.
repository: https://github.com/dart-lang/http/tree/master/pkgs/web_socket
version: 0.1.5
environment:
sdk: ^3.3.0
dev_dependencies:
dart_flutter_team_lints: ^2.0.0
test: ^1.24.0
web_socket_conformance_tests:
path: ../web_socket_conformance_tests/
dependencies:
web: ^0.5.0
Version history
| Version | Published | Archive | SHA-256 |
|---|---|---|---|
| 0.1.0 | 2024-03-20T00:10:16.556764Z | Download | 3f81fde6fbc799d03c0fb3f2c3ac84368ee267012a4beb876685c029946da4e0 |
| 0.1.1 | 2024-04-04T15:41:22.846491Z | Download | 6bbfb36ea811dac44d18511648687d5334cbad736f45880520f34995861d9b11 |
| 0.1.2 | 2024-04-17T00:00:05.120727Z | Download | 7c57c6d0eb006e64d962d5c832bbe2ae9adbd887829944065f7467cbe13f6d8f |
| 0.1.3 | 2024-04-25T22:01:51.738033Z | Download | bfe704c186c6e32a46f6607f94d079cd0b747b9a489fceeecc93cd3adb98edd5 |
| 0.1.4 | 2024-05-17T22:46:48.767515Z | Download | 217f49b5213796cb508d6a942a5dc604ce1cb6a0a6b3d8cb3f0c314f0ecea712 |
| 0.1.5 | 2024-05-28T17:45:55.539268Z | Download | 24301d8c293ce6fe327ffe6f59d8fd8834735f0ec36e4fd383ec7ff8a64aa078 |
| 0.1.6 | 2024-07-16T15:58:25.829234Z | Download | 3c12d96c0c9a4eec095246debcea7b86c0324f22df69893d538fcc6f1b8cce83 |
| 1.0.0 | 2025-04-17T20:32:34.265509Z | Download | bfe6f435f6ec49cb6c01da1e275ae4228719e59a6b067048c51e72d9d63bcc4b |
| 1.0.1 | 2025-05-06T00:19:01.236310Z | Download | 34d64019aa8e36bf9842ac014bb5d2f5586ca73df5e4d9bf5c936975cae6982c |
Dependencies
web "^0.5.0"