2.2.2 • Published 5 years ago

dlink-client v2.2.2

Weekly downloads
1
License
MIT
Repository
github
Last release
5 years ago

dlink-client

based socket.io-client

How to use

<script src="/dlink-client/dlink.js"></script>
<script>
  var socket = io('http://localhost');
  socket.on('connect', function(){});
  socket.on('event', function(data){});
  socket.on('disconnect', function(){});
</script>
// with ES6 import
import io from 'dlink-client';

const socket = io('http://localhost');

A slim build (without JSON3, a JSON polyfill for IE6/IE7, and debug) is also available: dlink.slim.js.

Node.JS (server-side usage)

Add dlink-client to your package.json and then:

var socket = require('dlink-client')('http://localhost:8080/namespace1');
socket.on('connect', function () {
  socket.subscribe('room1', msg => {
    console.log(msg);
  });
  socket.publish('room1', 'hello world');
});

socket.on('disconnect', function () {
  console.log('disconnect');
});

API

See API

License

MIT