p-hatan/ mirror

pub repository

mirror.p-hatan.com

web_socket

1.0.1

Any easy-to-use library for communicating with WebSockets that has multiple implementations.

Cached in Iran · Upstream SHA-256 matched

Download archive

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! 🎉');
}
Changelog

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.

Installing

export PUB_HOSTED_URL=https://pub.mirror.p-hatan.com
flutter pub add web_socket
pubspec.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: 1.0.1

environment:
  sdk: ^3.4.0

dependencies:
  web: '>=0.5.0 <2.0.0'

dev_dependencies:
  dart_flutter_team_lints: ^3.0.0
  test: ^1.24.0
  web_socket_conformance_tests:
    path: ../web_socket_conformance_tests/

Version history

VersionPublishedArchiveSHA-256
0.1.02024-03-20T00:10:16.556764ZCached3f81fde6fbc799d03c0fb3f2c3ac84368ee267012a4beb876685c029946da4e0
0.1.12024-04-04T15:41:22.846491ZCached6bbfb36ea811dac44d18511648687d5334cbad736f45880520f34995861d9b11
0.1.22024-04-17T00:00:05.120727ZCached7c57c6d0eb006e64d962d5c832bbe2ae9adbd887829944065f7467cbe13f6d8f
0.1.32024-04-25T22:01:51.738033ZCachedbfe704c186c6e32a46f6607f94d079cd0b747b9a489fceeecc93cd3adb98edd5
0.1.42024-05-17T22:46:48.767515ZCached217f49b5213796cb508d6a942a5dc604ce1cb6a0a6b3d8cb3f0c314f0ecea712
0.1.52024-05-28T17:45:55.539268ZCached24301d8c293ce6fe327ffe6f59d8fd8834735f0ec36e4fd383ec7ff8a64aa078
0.1.62024-07-16T15:58:25.829234ZCached3c12d96c0c9a4eec095246debcea7b86c0324f22df69893d538fcc6f1b8cce83
1.0.02025-04-17T20:32:34.265509ZCachedbfe6f435f6ec49cb6c01da1e275ae4228719e59a6b067048c51e72d9d63bcc4b
1.0.12025-05-06T00:19:01.236310ZCached34d64019aa8e36bf9842ac014bb5d2f5586ca73df5e4d9bf5c936975cae6982c

Dependencies

web "\u003e=0.5.0 \u003c2.0.0"