@cfware/peer-cluster

0.2.2 • Public • Published

@cfware/peer-cluster

Travis CI Greenkeeper badge NPM Version NPM Downloads MIT

Websocket all-to-all connectivity cluster.

Install @cfware/peer-cluster

This module requires node.js 12 or above with support for ESM modules. This has only been tested/used with esm.

npm i --save esm @cfware/peer-cluster

Usage

import {createServer} from 'http';

import pEvent from 'p-event';
import {PeerCluster} from '@cfware/peer-cluster';

(async () => {
	const httpd = createServer();
	httpd.listen(0);
	await pEvent(httpd, 'listening');

	const peerCluster = new PeerCluster({
		peerId: 'server1',
		origin: `ws://localhost:${httpd.address().port}/`,
		respond404: true
	});

	httpd.on('upgrade', (req, sock, head) => {
		cluster.tryUpgrade(req, sock, head);
	});
})();

Running tests

Tests are provided by xo and ava.

npm install
npm test

/@cfware/peer-cluster/

    Package Sidebar

    Install

    npm i @cfware/peer-cluster

    Weekly Downloads

    7

    Version

    0.2.2

    License

    MIT

    Unpacked Size

    15.8 kB

    Total Files

    11

    Last publish

    Collaborators

    • coreyfarrell