web_socket

v1.0.1

Any 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_socket

README

pub package package publisher

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:

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/WebSocketConnectionClosed did 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 1000 as a close code.

0.1.4

  • Add a fakes function that returns a pair of WebSockets useful in testing.

0.1.3

  • Bring the behavior in line with the documentation by throwing WebSocketConnectionClosed rather StateError when attempting to send data to or close an already closed WebSocket.

0.1.2

  • Fix a StateError in IOWebSocket when data is received from the peer after the connection has been closed locally.

0.1.1

  • Add the ability to create a package:web_socket WebSocket given a dart:io WebSocket.

0.1.0

  • Basic functionality in place.