socketcluster_client 0.0.3

  • README.md
  • CHANGELOG.md
  • Example
  • Installing
  • Versions
  • new56

SocketCluster Dart Client

Build Status Coverage Status

SocketCluster Client is the client-side component of SocketCluster.

Example Usage

  var socket = await Socket.connect('ws://localhost:8000/socketcluster/',
      listener: new MyListener());
      
  socket.on('rand', (name, data, ack) {
    print('got message $data from event $name');
    ack(name, 'No error', 'Hi there buddy');
  });

Note

This is a straight and dirty port from the C# client.

Large changes will be made to clean this up and make it more 'Dartified'

For instance, BasicListener will be removed in favor of Stream<Updates>

0.0.3

  • Allow listener to be optional.
  • Added test framework (Thanks to Michael Marner).

0.0.2

  • Added license.

0.0.1 - October 8th, 2018

  • Initial release.

example/main.dart

import 'package:socketcluster_client/socketcluster_client.dart';
import 'dart:async';

class MyListener extends BasicListener {
  @override
  void onAuthentication(Socket socket, bool status) {
    print('onAuthentication: socket $socket status $status');
  }

  @override
  void onConnectError(Socket socket, e) {
    print('onConnectError: socket $socket e $e');
  }

  @override
  void onConnected(Socket socket) {
    print('onConnected: socket $socket');
    new Timer.periodic(const Duration(seconds: 2), (_) {
      print('Attempting to send');
      socket.emit('sampleClientEvent',
          {'message': 'This is an object with a message property'});
    });
  }

  @override
  void onDisconnected(Socket socket) {
    print('onDisconnected: socket $socket');
  }

  @override
  void onSetAuthToken(String token, Socket socket) {
    print('onSetAuthToken: socket $socket token $token');
    socket.authToken = token;
  }
}

main() async {
  var socket = await Socket.connect('ws://localhost:8000/socketcluster/',
      listener: new MyListener());
  socket.on('rand', (name, data, ack) {
    print('got message $data from event $name');
    ack(name, 'No error', 'Hi there buddy');
  });
}

Use this package as a library

1. Depend on it

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


dependencies:
  socketcluster_client: ^0.0.3

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:socketcluster_client/socketcluster_client.dart';
  
Version Uploaded Documentation Archive
0.0.3 Oct 8, 2018 Go to the documentation of socketcluster_client 0.0.3 Download socketcluster_client 0.0.3 archive
0.0.2 Oct 8, 2018 Go to the documentation of socketcluster_client 0.0.2 Download socketcluster_client 0.0.2 archive
0.0.1 Oct 8, 2018 Go to the documentation of socketcluster_client 0.0.1 Download socketcluster_client 0.0.1 archive
Popularity:
Describes how popular the package is relative to other packages. [more]
24
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
70
Overall:
Weighted score of the above. [more]
56
Learn more about scoring.

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

  • Dart: 2.0.0
  • pana: 0.12.4

Platforms

Detected platforms: Flutter, other

Primary library: package:socketcluster_client/socketcluster_client.dart with components: io.

Health suggestions

Format lib/socketcluster_client.dart.

Run dartfmt to format lib/socketcluster_client.dart.

Format lib/src/channel.dart.

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

Format lib/src/emitter.dart.

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

Format lib/src/reconnect_strategy.dart.

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

Maintenance suggestions

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.

Package is pre-v0.1 release. (-10 points)

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

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0 <3.0.0
Dev dependencies
test ^1.3.0