New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

wsduck

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

wsduck

![Ducky](https://i.ibb.co/jMpg8Cq/wsducky.png) wsDuck is a module that lets you send websockets into "ponds," kinda like channels. # Examples **Attaching Ducky!** ```js const WebSocket = require("ws"); const wss = new WebSocket.Server({ port: 8080, client

latest
npmnpm
Version
3.2.1
Version published
Maintainers
1
Created
Source

Ducky wsDuck is a module that lets you send websockets into "ponds," kinda like channels.

Examples

Attaching Ducky!

const WebSocket = require("ws");
const wss = new WebSocket.Server({ port: 8080, clientTracking: true });
const ducky = require("wsducky")(wss);

Making a pond and connecting a websocket to it!

const WebSocket = require("ws");
const wss = new WebSocket.Server({ port: 8080, clientTracking: true });
const ducky = require("wsducky")(wss);
var myPond = ducky.createPond();
wss.on('connection', function connection(ws) {
  myPond.connect(ws);
});

Listening for events on the pond!

const WebSocket = require("ws");
const wss = new WebSocket.Server({ port: 8080, clientTracking: true });
const ducky = require("wsducky")(wss);
var myPond = ducky.createPond();
wss.on('connection', function connection(ws) {
  myPond.connect(ws);
});
pond.event.on("message", (message) => {
	console.log(message);
});
pond.event.on("disconnection", (ws) => {
	// awh.....
});

Properties of a duckling!

const WebSocket = require("ws");
const wss = new WebSocket.Server({ port: 8080, clientTracking: true });
const ducky = require("wsducky")(wss);
var myPond = ducky.createPond();
wss.on('connection', function connection(ws) {
  var duckling = myPond.connect(ws);
  // duckling.ws (original websocket)
  duckling.disconnect();
});

Listing the ducklings!

const WebSocket = require("ws");
const wss = new WebSocket.Server({ port: 8080, clientTracking: true });
const ducky = require("wsducky")(wss);
var myPond = ducky.createPond();
myPond.list(); // returns an object with values ws and disconnect (function)

Deleting the pond..

const WebSocket = require("ws");
const wss = new WebSocket.Server({ port: 8080, clientTracking: true });
const ducky = require("wsducky")(wss);
var myPond = ducky.createPond();
myPond.destroy();

Keywords

ws

FAQs

Package last updated on 09 Sep 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts