socket_io_client 0.9.1

  • README.md
  • Installing
  • Versions
  • 66

socket.io-client-dart #

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

Usage #

import 'package:socket_io/socket_io.dart';
import 'package:socket_io_client/socket_io_client.dart' as IO;

main() {
    // Dart server
    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);

    // Dart client
    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(_));
}

Notes to Contributors #

Fork socket.io-client-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 Server #

Contributors #

Use this package as a library

1. Depend on it

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


dependencies:
  socket_io_client: ^0.9.1

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 flutter packages 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_client/socket_io_client.dart';
  
Version Uploaded Documentation Archive
0.9.1 Jan 21, 2019 Go to the documentation of socket_io_client 0.9.1 Download socket_io_client 0.9.1 archive
0.9.0+1 Nov 20, 2018 Go to the documentation of socket_io_client 0.9.0+1 Download socket_io_client 0.9.0+1 archive
0.9.0 Nov 20, 2018 Go to the documentation of socket_io_client 0.9.0 Download socket_io_client 0.9.0 archive
0.8.2 Jun 4, 2018 Go to the documentation of socket_io_client 0.8.2 Download socket_io_client 0.8.2 archive
0.8.1 May 25, 2018 Go to the documentation of socket_io_client 0.8.1 Download socket_io_client 0.8.1 archive
0.8.0 Apr 9, 2018 Go to the documentation of socket_io_client 0.8.0 Download socket_io_client 0.8.0 archive
Popularity:
Describes how popular the package is relative to other packages. [more]
88
Health:
Code health derived from static analysis. [more]
53
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
30
Overall:
Weighted score of the above. [more]
66
Learn more about scoring.

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

  • Dart: 2.2.0
  • pana: 0.12.14

Platforms

Detected platforms: Flutter, web, other

No platform restriction found in primary library package:socket_io_client/socket_io_client.dart.

Health suggestions

Fix lib/src/manager.dart. (-15.25 points)

Analysis of lib/src/manager.dart reported 33 hints, including:

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

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

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

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

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

Fix lib/src/engine/socket.dart. (-10.44 points)

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

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

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

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

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

line 263 col 16: Use isEmpty instead of length

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

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

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

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

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

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

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

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

Additional issues in the following files:

  • lib/src/engine/transport/xhr_transport.dart (15 hints)
  • lib/src/engine/transport/polling_transport.dart (9 hints)
  • lib/src/engine/transport/transport.dart (8 hints)
  • lib/src/engine/transport/jsonp_transport.dart (6 hints)
  • lib/src/engine/transport/io_websocket_transport.dart (4 hints)
  • lib/src/engine/transport/websocket_transport.dart (4 hints)
  • lib/src/engine/parseqs.dart (3 hints)
  • lib/socket_io_client.dart (2 hints)
  • lib/src/on.dart (1 hint)
  • lib/src/engine/transport/io_transports.dart (Run dartfmt to format lib/src/engine/transport/io_transports.dart.)
  • lib/src/engine/transport/transports_stub.dart (Run dartfmt to format lib/src/engine/transport/transports_stub.dart.)

Maintenance issues and suggestions

Provide a file named CHANGELOG.md. (-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 1 dependency without version constraints. Specify version ranges for the following dependencies: socket_io_common.

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_client.dart. Packages with multiple examples should provide example/README.md.

For more information see the pub package layout conventions.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0 <3.0.0
logging ^0.11.3+2 0.11.3+2
socket_io_common any 0.9.0+5
Dev dependencies
build_runner ^1.0.0
build_web_compilers ^0.4.4
socket_io any
test >=1.3.0 <2.0.0