socket.io-adapter-cluster

1.0.1 • Public • Published

socket.io-adapter-cluster

How to use

worker.js

const io = require('socket.io')(3000);
const clusterAdapter = require('socket.io-adapter-cluster');
 
io.adapter(clusterAdapter());

master.js

const cluster = require('cluster');
const clusterAdapter = require('socket.io-adapter-cluster/master');
 
cluster.setupMaster({
  exec: 'worker.js',
});
cluster.fork();
 
clusterAdapter();

API

Adapter([opts])

The following opts are allowed:

  • key: the name of broadcast prefix, default(socket.io)
  • client: the client of broadcast

Protocal

The socket.io-adapter-cluster adapter broadcast with prefix:

prefix#namespace#

If broadcasting to a single room:

prefix#namespace#room#

Note

The socket.io-adapter-cluster is a simple and cluster-version of socket.io-redis.

LICENSE

MPL-2.0

Package Sidebar

Install

npm i socket.io-adapter-cluster

Weekly Downloads

12

Version

1.0.1

License

MPL-2.0

Unpacked Size

7.08 kB

Total Files

6

Last publish

Collaborators

  • zunsthy