socket_io 0.9.3

  • Readme
  • Changelog
  • Example
  • Installing
  • 92

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', (client) {
      print('connection /some');
      client.on('msg', (data) {
        print('data from /some => $data');
        client.emit('fromServer', "ok 2");
      });
    });
      io.on('connection', (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 #

0.9.3 #

Bug Fix:

  • #18 make sure it is accessing the rooms map

0.9.2 #

Bug Fix:

  • #17 inference error

0.9.1+1 #

New Feature:

  • #16 Apply Pedantic recommendations

example/README.md

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', (client) {
      print('connection /some');
      client.on('msg', (data) {
        print('data from /some => $data');
        client.emit('fromServer', "ok 2");
      });
    });
      io.on('connection', (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 #

Use this package as a library

1. Depend on it

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


dependencies:
  socket_io: ^0.9.3

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';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
84
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
92
Learn more about scoring.

We analyzed this package on Mar 30, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.7.1
  • pana: 0.13.6

Health suggestions

Format lib/src/engine/socket.dart.

Run dartfmt to format lib/src/engine/socket.dart.

Format lib/src/engine/transport/websocket_transport.dart.

Run dartfmt to format lib/src/engine/transport/websocket_transport.dart.

Format lib/src/namespace.dart.

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

Format lib/src/socket.dart.

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

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0 <3.0.0
logging ^0.11.3+2 0.11.4
socket_io_common ^0.9.0+5 0.9.1
stream ^2.2.1+1 2.2.2
uuid ^2.0.4 2.0.4
Transitive dependencies
args 1.6.0
async 2.4.1
charcode 1.1.3
collection 1.14.12
convert 2.1.1
crypto 2.1.4
http 0.12.0+4
http_parser 3.1.4
meta 1.1.8
mime 0.9.6+3
path 1.6.4
rikulo_commons 4.0.1
source_span 1.7.0
string_scanner 1.0.5
term_glyph 1.1.0
typed_data 1.1.6
Dev dependencies
pedantic ^1.9.0 1.9.0
test >=1.3.0 <2.0.0