Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/siarheidudko/redux-cluster-ws
Wrapper to ReduxCluster library (add websocket functionaly)
https://github.com/siarheidudko/redux-cluster-ws
Last synced: about 16 hours ago
JSON representation
Wrapper to ReduxCluster library (add websocket functionaly)
- Host: GitHub
- URL: https://github.com/siarheidudko/redux-cluster-ws
- Owner: siarheidudko
- License: mit
- Created: 2019-03-07T10:04:37.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2022-12-03T01:11:47.000Z (almost 2 years ago)
- Last Synced: 2024-11-01T16:47:34.975Z (6 days ago)
- Language: JavaScript
- Homepage:
- Size: 686 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 14
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Redux-Cluster-Ws
Web-socket wrapper to Redux-Cluster library.[![npm](https://img.shields.io/npm/v/redux-cluster-ws.svg)](https://www.npmjs.com/package/redux-cluster-ws)
[![npm](https://img.shields.io/npm/dy/redux-cluster-ws.svg)](https://www.npmjs.com/package/redux-cluster-ws)
[![NpmLicense](https://img.shields.io/npm/l/redux-cluster-ws.svg)](https://www.npmjs.com/package/redux-cluster-ws)
![GitHub last commit](https://img.shields.io/github/last-commit/siarheidudko/redux-cluster-ws.svg)
![GitHub release](https://img.shields.io/github/release/siarheidudko/redux-cluster-ws.svg)## Install
[Please see api for Redux-Cluster](https://github.com/siarheidudko/redux-cluster)```
npm i redux-cluster redux-cluster-ws --save
```## Add websocket server wrapper and use
```
require('redux-cluster-ws').server(Test);
Test.createWSServer();
```
### Example
```
require('redux-cluster-ws').server(Test);
Test.createWSServer({
host: "0.0.0.0",
port: 8888,
logins:{
test2:'123456'
},
ssl:{
key: /path/to/certificate-key,
crt: /path/to/certificate,
ca: /path/to/certificate-ca
}
});require('redux-cluster-ws').server(Test2);
Test2.createWSServer({
host: "localhost",
port: 8889,
logins:{
test2:'123456'
}
});
```
Options Required:
- server - instance of http.Server or https.Server (or use host and port option)
- host - hostname or ip-address (or use server option)
- port - port (optional, default 10002, or use server option)
- logins - login - password pairs as `{login1:password1, login2:password2}`.
- ssl - path to server certificate (if use as https, default use http).
## Add websocket client library
Client does not use internal Node libraries for webpack compatibility. Therefore, on the client, you must create a store with the same reducer.```
//create Redux Store
var ReduxClusterWS = require('redux-cluster-ws').client;
var Test = ReduxClusterWS.createStore();//connect to Redux-Cluster server (use socket.io)
Test.createWSClient();
```
### Example
```
var Test = ReduxCluster.createStore(reducer);
Test.createWSClient({host: "https://localhost", port: 8888, login:"test2", password:'123456'});
```
Options Required:
- host - hostname or ip-address (protocol include)
- port - port (optional, default 10002)
- login - login in websocket
- password - password in websocket
## LICENSE
MIT