Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

elws

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

elws - npm Package Compare versions

Comparing version 1.0.0 to 1.0.2

38

package.json
{
"name": "elws",
"version": "1.0.0",
"version": "1.0.2",
"description": "Simple auto-reconnect WebSocket decorator",
"main": "rws.js",
"scripts": {
"test": "npm run lint && mocha",
"lint": "eslint rwebsocket.js test"
},
"repository": {

@@ -27,35 +23,5 @@ "type": "git",

"homepage": "https://github.com/116356754/elws#readme",
"devDependencies": {
"eslint": "^3.12.2",
"mocha": "^3.2.0"
},
"dependencies": {
"ws": "^1.1.1",
"bufferutil": "^1.3.0",
"utf-8-validate": "^2.0.0"
},
"optionalDependencies": {
"bufferutil": "^1.3.0",
"utf-8-validate": "^2.0.0"
},
"eslintConfig": {
"env": {
"node": true
},
"extends": [
"eslint:recommended"
],
"rules": {
"semi": 2,
"no-use-before-define": 2,
"space-before-function-paren": [
"error",
{
"anonymous": "always",
"named": "never",
"asyncArrow": "ignore"
}
]
}
"ws": "^1.1.1"
}
}

22

README.md

@@ -1,2 +0,2 @@

# rwebsocket [![Build Status](https://travis-ci.org/maxleiko/rwebsocket.svg?branch=master)](https://travis-ci.org/maxleiko/rwebsocket)
# elws
Simple auto-reconnect WebSocket adapter

@@ -11,5 +11,5 @@

```js
const RWebSocket = require('elws');
const RWS = require('elws');
const client = new RWebSocket('ws://echo.websocket.org;ws://localhost:8080');
const client = new RWS('ws://echo.websocket.org;ws://localhost:8080');

@@ -30,2 +30,8 @@ client.onopen = function () {

client.connect();
//close
setTimeout(function(){
console.log('timeout ');
client.forceClose(1000);
},10000);
```

@@ -39,8 +45,16 @@

- the ability to give a 3rd argument to the constructor to set the `retryInterval` in `ms`
- the ability to give a 4rth argument to the constructor to set the `retryCount`
- the `#connect()` method to actually create a WebSocket and connect to the server
```js
const client = new RWebSocket('ws://echo.websocket.org;ws://localhost:8080', null, 25000,5);
const client = new RWS('ws://echo.websocket.org;ws://localhost:8080', null, 25000,5);
```
> Reconnection attempts will be made once every 25 seconds, and try 5 times then switch another url.
> NB: the 'null' param is for the protocol because the constructor is the same as the [WebSocket RFC](https://developer.mozilla.org/en-US/docs/Web/API/WebSocket) + `retryInterval`
the ability to give a one argument to the constructor to set the close event 'code'
```js
client.forceClose(1000);
```

@@ -36,2 +36,3 @@ var WebSocket = require('ws');

this.client.onclose = function (event) {
console.log(event.code);
switch (event.code) {

@@ -93,6 +94,12 @@ case 1000:

};
this.client.stopTimeout = function(){
clearTimeout(connectTimeout);
connectTimeout = null;
}
},
close: function (code, reason) {
forceClose: function (code, reason) {
if (this.client) {
this.client.stopTimeout();
this.client.close(code || 1000, reason);

@@ -99,0 +106,0 @@ }

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc