socket_io 0.9.0+2 #

Port of awesome JavaScript Node.js library - v2.0.1 - in Dart

Usage #

import 'package:socket_io/socket_io.dart';

main() {
    var io = new Server();
    var nsp = io.of('/some');
    nsp.on('connection', (Socket client) {
      print('connection /some');
      client.on('msg', (data) {
        print('data from /some => $data');
        client.emit('fromServer', "ok 2");
      io.on('connection', (Socket client) {
        print('connection default namespace');
        client.on('msg', (data) {
          print('data from default => $data');
          client.emit('fromServer', "ok");
// JS client
var socket = io('http://localhost:3000');
socket.on('connect', function(){console.log('connect')});
socket.on('event', function(data){console.log(data)});
socket.on('disconnect', function(){console.log('disconnect')});
socket.on('fromServer', function(e){console.log(e)});
// Dart client
import 'package:socket_io_client/socket_io_client.dart' as IO;

IO.Socket socket ='http://localhost:3000');
socket.on('connect', (_) {
  socket.emit('msg', 'test');
socket.on('event', (data) => print(data));
socket.on('disconnect', (_) => print('disconnect'));
socket.on('fromServer', (_) => print(_));

Multiplexing support #

Same as Socket.IO, this project allows you to create several Namespaces, which will act as separate communication channels but will share the same underlying connection.

Room support #

Within each Namespace, you can define arbitrary channels, called Rooms, that sockets can join and leave. You can then broadcast to any given room, reaching every socket that has joined it.

Transports support #

Refers to

  • polling: XHR / JSONP polling transport.
  • websocket: WebSocket transport.

Adapters support #

Notes to Contributors #

Fork #

If you'd like to contribute back to the core, you can fork this repository and send us a pull request, when it is ready.

If you are new to Git or GitHub, please read this guide first.

Who Uses #

  • Quire - a simple, collaborative, multi-level task management tool.
  • KEIKAI - a web spreadsheet for Big Data. Dart Client #

Contributors #

Use this package as a library

1. Depend on it

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

  socket_io: ^0.9.0+2

2. Install it

You can install packages from the command line:

with pub:

$ pub get

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

3. Import it

Now in your Dart code, you can use:

import 'package:socket_io/socket_io.dart';
Describes how popular the package is relative to other packages. [more]
Code health derived from static analysis. [more]
Reflects how tidy and up-to-date the package is. [more]
Weighted score of the above. [more]
Learn more about scoring.

We analyzed this package on Nov 8, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.6.0
  • pana: 0.12.21


Detected platforms: other

Primary library: package:socket_io/socket_io.dart with components: io, mirrors.

Health suggestions

Fix lib/src/socket.dart. (-9.99 points)

Analysis of lib/src/socket.dart reported 21 hints, including:

line 26 col 1: Prefer using /// for doc comments.

line 40 col 1: Prefer using /// for doc comments.

line 85 col 3: Prefer using /// for doc comments.

line 136 col 3: Prefer using /// for doc comments.

line 185 col 3: Prefer using /// for doc comments.

Fix lib/src/server.dart. (-9.54 points)

Analysis of lib/src/server.dart reported 20 hints, including:

line 24 col 1: Prefer using /// for doc comments.

line 48 col 3: Prefer using /// for doc comments.

line 55 col 11: Don't explicitly initialize variables to null.

line 55 col 17: Use = to separate a named parameter from its default value.

line 70 col 3: Prefer using /// for doc comments.

Fix lib/src/engine/server.dart. (-9.08 points)

Analysis of lib/src/engine/server.dart reported 19 hints, including:

line 23 col 1: Prefer using /// for doc comments.

line 92 col 9: DO use curly braces for all flow control structures.

line 96 col 7: DO use curly braces for all flow control structures.

line 102 col 3: Prefer using /// for doc comments.

line 129 col 3: Prefer using /// for doc comments.

Fix additional 11 files with analysis or formatting issues. (-42.71 points)

Additional issues in the following files:

  • lib/src/engine/socket.dart (17 hints)
  • lib/src/client.dart (15 hints)
  • lib/src/namespace.dart (15 hints)
  • lib/src/engine/transport/polling_transport.dart (12 hints)
  • lib/src/adapter/adapter.dart (11 hints)
  • lib/src/util/event_emitter.dart (11 hints)
  • lib/src/engine/connect.dart (2 hints)
  • lib/src/engine/transport/jsonp_transport.dart (2 hints)
  • lib/src/engine/transport/xhr_transport.dart (2 hints)
  • lib/src/engine/engine.dart (1 hint)
  • lib/socket_io.dart (Run dartfmt to format lib/socket_io.dart.)

Maintenance issues and suggestions

Provide a file named (-20 points)

Changelog entries help developers follow the progress of your package. See the example generated by stagehand.

Use constrained dependencies. (-20 points)

The pubspec.yaml contains 3 dependencies without version constraints. Specify version ranges for the following dependencies: socket_io_common, stream, uuid.

Use analysis_options.yaml. (-10 points)

Change the name of your package's .analysis_options file to analysis_options.yaml.

Read more about the setup of analysis-options.yaml.

The package description is too short. (-20 points)

Add more detail to the description field of pubspec.yaml. Use 60 to 180 characters to describe the package, what it does, and its target use case.

Maintain an example. (-10 points)

Create a short demo in the example/ directory to show how to use this package.

Common filename patterns include main.dart, example.dart, and socket_io.dart. Packages with multiple examples should provide example/

For more information see the pub package layout conventions.


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0 <3.0.0
socket_io_common any 0.9.0+5
stream any 2.2.1
uuid any 2.0.2
Transitive dependencies
args 1.5.2
async 2.4.0
charcode 1.1.2
collection 1.14.12
convert 2.1.1
crypto 2.1.3
http 0.12.0+2
http_parser 3.1.3
logging 0.11.3+2
meta 1.1.8
mime 0.9.6+3
path 1.6.4
pedantic 1.8.0+1
rikulo_commons 3.3.1
source_span 1.5.5
string_scanner 1.0.5
term_glyph 1.1.0
typed_data 1.1.6
Dev dependencies
test >=1.3.0 <2.0.0