p-hatan/ mirror

pub repository

mirror.p-hatan.ir

web_socket

0.1.4

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

Download archive

Readme

pub package package publisher

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

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.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.ir
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: 0.1.4

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

VersionPublishedArchiveSHA-256
0.1.02024-03-20T00:10:16.556764ZDownload3f81fde6fbc799d03c0fb3f2c3ac84368ee267012a4beb876685c029946da4e0
0.1.12024-04-04T15:41:22.846491ZDownload6bbfb36ea811dac44d18511648687d5334cbad736f45880520f34995861d9b11
0.1.22024-04-17T00:00:05.120727ZDownload7c57c6d0eb006e64d962d5c832bbe2ae9adbd887829944065f7467cbe13f6d8f
0.1.32024-04-25T22:01:51.738033ZDownloadbfe704c186c6e32a46f6607f94d079cd0b747b9a489fceeecc93cd3adb98edd5
0.1.42024-05-17T22:46:48.767515ZDownload217f49b5213796cb508d6a942a5dc604ce1cb6a0a6b3d8cb3f0c314f0ecea712
0.1.52024-05-28T17:45:55.539268ZDownload24301d8c293ce6fe327ffe6f59d8fd8834735f0ec36e4fd383ec7ff8a64aa078
0.1.62024-07-16T15:58:25.829234ZDownload3c12d96c0c9a4eec095246debcea7b86c0324f22df69893d538fcc6f1b8cce83
1.0.02025-04-17T20:32:34.265509ZDownloadbfe6f435f6ec49cb6c01da1e275ae4228719e59a6b067048c51e72d9d63bcc4b
1.0.12025-05-06T00:19:01.236310ZDownload34d64019aa8e36bf9842ac014bb5d2f5586ca73df5e4d9bf5c936975cae6982c

Dependencies

web "^0.5.0"