shelf_web_socket 0.2.2

  • README.md
  • CHANGELOG.md
  • Installing
  • Versions
  • 94

Web Socket Handler for Shelf

shelf_web_socket is a Shelf handler for establishing WebSocket connections. It exposes a single function, webSocketHandler, which calls an onConnection callback with a CompatibleWebSocket object for every connection that's established.

import 'package:shelf/shelf_io.dart' as shelf_io;
import 'package:shelf_web_socket/shelf_web_socket.dart';

void main() {
  var handler = webSocketHandler((webSocket) {
    webSocket.listen((message) {
      webSocket.add("echo $message");
    });
  });

  shelf_io.serve(handler, 'localhost', 8080).then((server) {
    print('Serving at ws://${server.address.host}:${server.port}');
  });
}

0.2.2

  • Stop using comment-based generic syntax.

0.2.1

  • Fix all strong-mode warnings.

0.2.0

  • Breaking change: webSocketHandler() now uses the WebSocketChannel class defined in the web_socket_channel package, rather than the deprecated class defined in http_parser.

0.1.0

  • Breaking change: webSocketHandler() now passes a WebSocketChannel to the onConnection() callback, rather than a deprecated CompatibleWebSocket.

0.0.1+5

  • Support http_parser 2.0.0.

0.0.1+4

  • Fix a link to shelf in the README.

0.0.1+3

  • Support http_parser 1.0.0.

0.0.1+2

  • Mark as compatible with version 0.6.0 of shelf.

0.0.1+1

  • Properly parse the Connection header. This fixes an issue where Firefox was unable to connect.

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  shelf_web_socket: "^0.2.2"

2. Install it

You can install packages from the command line:

with pub:


$ pub get

with Flutter:


$ flutter packages get

Alternatively, your editor might support pub get or packages get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:shelf_web_socket/shelf_web_socket.dart';
        
Version Uploaded Documentation Archive
0.2.2 Sep 27, 2017 Go to the documentation of shelf_web_socket 0.2.2 Download shelf_web_socket 0.2.2 archive
0.2.1 May 11, 2016 Go to the documentation of shelf_web_socket 0.2.1 Download shelf_web_socket 0.2.1 archive
0.2.0 Mar 3, 2016 Go to the documentation of shelf_web_socket 0.2.0 Download shelf_web_socket 0.2.0 archive
0.1.0 Feb 1, 2016 Go to the documentation of shelf_web_socket 0.1.0 Download shelf_web_socket 0.1.0 archive
0.0.1+5 Dec 14, 2015 Go to the documentation of shelf_web_socket 0.0.1+5 Download shelf_web_socket 0.0.1+5 archive
0.0.1+4 Aug 27, 2015 Go to the documentation of shelf_web_socket 0.0.1+4 Download shelf_web_socket 0.0.1+4 archive
0.0.1+3 Aug 26, 2015 Go to the documentation of shelf_web_socket 0.0.1+3 Download shelf_web_socket 0.0.1+3 archive
0.0.1+2 Mar 5, 2015 Go to the documentation of shelf_web_socket 0.0.1+2 Download shelf_web_socket 0.0.1+2 archive
0.0.1+1 Dec 18, 2014 Go to the documentation of shelf_web_socket 0.0.1+1 Download shelf_web_socket 0.0.1+1 archive
0.0.1 May 20, 2014 Go to the documentation of shelf_web_socket 0.0.1 Download shelf_web_socket 0.0.1 archive

Analysis

This feature is new.
We welcome feedback.
More details: scoring.

We analyzed this package, and provided a score, details, and suggestions below.

  • completed on Jan 17, 2018
  • Dart: 2.0.0-dev.15.0
  • pana: 0.9.1

Scores

Popularity:
Describes how popular the package is relative to other packages. [more]
90 / 100
Health:
Code health derived from static analysis. [more]
98 / 100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100 / 100
Overall score:
Weighted score of the above. [more]
94

Platforms

Detected platforms: Flutter, server, web

No platform restriction found in libraries.

Suggestions

  • The description is too short.

    Add more detail about the package, what it does and what is its target use case. Try to write at least 60 characters.

  • Package is pre-v1 release.

    While there is nothing inherently wrong with versions of 0.*.*, it usually means that the author is still experimenting with the general direction API.

  • Maintain an example.

    Create a short demo in the example/ directory to show how to use this package. Common file name patterns include: main.dart, example.dart or you could also use shelf_web_socket.dart.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=1.21.0 <2.0.0
shelf >=0.6.5 <0.8.0 0.7.2
stream_channel ^1.4.0 1.6.3
web_socket_channel ^1.0.0 1.0.6
Transitive dependencies
async 2.0.3
charcode 1.1.1
collection 1.14.5
convert 2.0.1
crypto 2.0.2+1
http_parser 3.1.1
path 1.5.1
source_span 1.4.0
stack_trace 1.9.1
string_scanner 1.0.2
typed_data 1.1.5
Dev dependencies
http >=0.10.0 <0.12.0
test ^0.12.0