Skip to content
This repository was archived by the owner on Nov 2, 2020. It is now read-only.

Installation and Configuration

Dmitrii Goriunov edited this page Feb 18, 2019 · 12 revisions

JavaScript

Page Content:

Installation:

There are two ways you can install ClusterWS Client JS library

  • Use npm to install (only for projects which are using some kinda bundle libraries/frameworks such as Webpack, Gulp, Rollup, ...)
npm i--save clusterws-client-js
  • Import globally into the HTML script:
  1. Navigate to dist/browser in repo.
  2. Copy clusterws.[min].js to your project.
  3. Import it in html with <script src="path/to/clusterws.[min].js"></script>.
  4. Don't forget to take LICENSE file (of cause not many people will do that so just give as stars ⭐)

Simple Configuration:

To connect to the server use ClusterWS instance:

// if you used npm you have to import it like below
const ClusterWS = require('clusterws-client-js') 

let socket = new ClusterWS({
    url: 'ws://localhost:80'
})

Available Configurations

  • url: {string} url to the server with ws/wss and port like ws://localhost:80. (must be provided).
  • autoReconnect: {boolean} allow to auto-reconnect to the server on lost connection with code which is not equal 1000. (default false).
  • autoReconnectOptions: {object} additional auto reconnect configurations (optional).
    • attempts: {number} how many times try to reconnect, 0 means unlimited amount. (default 0)
    • minInterval: {number} min amount to wait before next attempt to connect. (default 1000)
    • maxInterval: {number} max amount to wait before next attempt to connect. (default 5000)
  • encodeDecodeEngine: {object} allow to implement custom encode decode system for your messages (optional).
    • encode: {function} function which gets message as param and must return message back (after encoding).
    • decode: {function} function which gets message as param and must return message back (after decoding).

English:

1. Home

2. Installation and Configuration

3. Handle Socket

4. Pub/Sub System

5. Client to Client Communication

Other languages will be added later

Clone this wiki locally