dlink-client

2.2.2 • Public • Published

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

Package Sidebar

Install

npm i dlink-client

Weekly Downloads

4

Version

2.2.2

License

MIT

Unpacked Size

1.57 MB

Total Files

16

Last publish

Collaborators

  • shine_yjg