This repository was archived by the owner on Nov 2, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 10
Installation and Configuration
Dmitrii Goriunov edited this page Feb 18, 2019
·
12 revisions
Page Content:
There are two ways you can install ClusterWS Client JS library
- Use
npmto install (only for projects which are using some kinda bundle libraries/frameworks such asWebpack,Gulp,Rollup,...)
npm i--save clusterws-client-js- Import globally into the
HTMLscript:
- Navigate to
dist/browserin repo. - Copy
clusterws.[min].jsto your project. - Import it in html with
<script src="path/to/clusterws.[min].js"></script>. - Don't forget to take
LICENSEfile (of cause not many people will do that so just give as stars ⭐)
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'
})-
url:
{string}url to the server withws/wssandportlikews://localhost:80. (must be provided). -
autoReconnect:
{boolean}allow to auto-reconnect to the server on lost connection with code which is not equal1000. (defaultfalse). -
autoReconnectOptions:
{object}additional auto reconnect configurations (optional).-
attempts:
{number}how many times try to reconnect,0means unlimited amount. (default0) -
minInterval:
{number}min amount to wait before next attempt to connect. (default1000) -
maxInterval:
{number}max amount to wait before next attempt to connect. (default5000)
-
attempts:
-
encodeDecodeEngine:
{object}allow to implement custom encode decode system for your messages (optional).-
encode:
{function}function which getsmessageas param and must return message back (after encoding). -
decode:
{function}function which getsmessageas param and must return message back (after decoding).
-
encode:
💥 We would really appreciate if you give us stars ⭐ (on all our repositories):
For you to give the stars ⭐ is not hard, but for us, it is a huge motivation to work harder and improve the project. Thank you very much 😄.
1. Home
2. Installation and Configuration
5. Client to Client Communication
Other languages will be added later