socket_io 0.9.0+1

  • README.md
  • Installing
  • Versions
  • 73

socket.io-dart

Port of awesome JavaScript Node.js library - Socket.io 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");
        });
      });
      io.listen(3000);
}

// 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 = IO.io('http://localhost:3000');
socket.on('connect', (_) {
  print('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 engine.io

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

Adapters support

Notes to Contributors

Fork socket.io-dart

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.

Socket.io Dart Client

Contributors

Use this package as a library

1. Depend on it

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


dependencies:
  socket_io: ^0.9.0+1

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';
  
Version Uploaded Documentation Archive
0.9.0+1 Nov 20, 2018 Go to the documentation of socket_io 0.9.0+1 Download socket_io 0.9.0+1 archive
0.9.0 Nov 20, 2018 Go to the documentation of socket_io 0.9.0 Download socket_io 0.9.0 archive
0.8.2 Jul 20, 2018 Go to the documentation of socket_io 0.8.2 Download socket_io 0.8.2 archive
0.8.1 Jun 4, 2018 Go to the documentation of socket_io 0.8.1 Download socket_io 0.8.1 archive
0.8.0 Apr 9, 2018 Go to the documentation of socket_io 0.8.0 Download socket_io 0.8.0 archive
Popularity:
Describes how popular the package is relative to other packages. [more]
79
Health:
Code health derived from static analysis. [more]
99
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
20
Overall:
Weighted score of the above. [more]
73
Learn more about scoring.

We analyzed this package on Dec 5, 2018, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.1.0
  • pana: 0.12.7

Platforms

Detected platforms: other

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

Health suggestions

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

Analysis of lib/src/engine/server.dart reported 2 hints:

line 306 col 9: Equality operator == invocation with references of unrelated types.

line 398 col 13: Equality operator == invocation with references of unrelated types.

Format lib/socket_io.dart.

Run dartfmt to format lib/socket_io.dart.

Format lib/src/client.dart.

Run dartfmt to format lib/src/client.dart.

Maintenance issues and suggestions

Maintain CHANGELOG.md. (-20 points)

Changelog entries help clients to follow the progress in your code.

Use constrained dependencies. (-20 points)

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

Use analysis_options.yaml. (-10 points)

Rename old .analysis_options file to analysis_options.yaml.

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

The description is too short. (-20 points)

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

Maintain an example. (-10 points)

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 socket_io.dart.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0 <3.0.0
socket_io_common any 0.9.0+1
stream any 2.1.0
Transitive dependencies
args 1.5.1
async 2.0.8
charcode 1.1.2
collection 1.14.11
convert 2.0.2
crypto 2.0.6
http 0.12.0
http_parser 3.1.3
logging 0.11.3+2
meta 1.1.6
mime 0.9.6+2
path 1.6.2
rikulo_commons 3.1.0+1
source_span 1.4.1
string_scanner 1.0.4
typed_data 1.1.6
uuid 1.0.3
Dev dependencies
test >=1.3.0 <2.0.0