web_socket
v1.0.1Any easy-to-use library for communicating with WebSockets that has multiple implementations.
Архив пакета: https://pubdev.letsnova.ru/api/archives/web_socket/1.0.1.tar.gz
dart pub add web_socketREADME
An 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 the most popular WebSocket package but it is complex and does not have
consistent behavior across implementations.
WebSocket
currently has four implementations that all pass the same set of
conformance tests:
BrowserWebSocketCupertinoWebSocketIOWebSocketOkHttpWebSocket(currently experimental)
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! 🎉');
}
История изменений
1.0.1
- Fix a bug where
WebSocketException/WebSocketConnectionCloseddid not have a useful string representation.
1.0.0
- First non-experimental release; no semantic changes from version
0.1.6.
0.1.6
- Allow
web: '>=0.5.0 <2.0.0'.
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.
