fastify-ws
Advanced tools
Comparing version 0.1.1 to 0.2.0
16
index.js
@@ -15,18 +15,2 @@ 'use strict' | ||
const keepAlive = ws => { | ||
ws.alive = true | ||
const stayAlive = () => { ws.alive = true } | ||
ws.on('pong', stayAlive) | ||
} | ||
wss.on('connection', keepAlive) | ||
const pingInterval = Number.parseInt(opts.pingInterval, 10) || 30000 | ||
setInterval(() => wss.clients.forEach(ws => { | ||
if (ws.alive === false) return ws.terminate() | ||
ws.alive = false | ||
ws.ping('', false, true) | ||
}), pingInterval) | ||
fastify.decorate('wsServer', wss) | ||
@@ -33,0 +17,0 @@ |
{ | ||
"name": "fastify-ws", | ||
"version": "0.1.1", | ||
"version": "0.2.0", | ||
"description": "Basic WebSocket support for Fastify built on the blazing fast ws and uws libraries.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
# fastify-ws | ||
[![Build Status](https://travis-ci.org/gj/fastify-ws.svg?branch=master)](https://travis-ci.org/gj/fastify-ws) | ||
[![Build Status](https://travis-ci.org/gj/fastify-ws.svg?branch=master)](https://travis-ci.org/gj/fastify-ws) [![npm version](https://badge.fury.io/js/fastify-ws.svg)](https://www.npmjs.com/package/fastify-ws) | ||
@@ -15,3 +15,2 @@ WebSocket support for [Fastify](https://github.com/fastify/fastify) built on the blazing fast [ws](http://npm.im/ws) and [uws](http://npm.im/uws) libraries. | ||
fastify.register(require('fastify-ws'), { | ||
pingInterval: 10000, // Keep the connection alive by sending pings every 10 seconds (default: 30 seconds) | ||
wsLibrary: 'uws' // Use the uws library instead of the default ws library | ||
@@ -18,0 +17,0 @@ }) |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
5002
45
54