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

socket.io-adapter

Package Overview
Dependencies
Maintainers
2
Versions
29
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

socket.io-adapter - npm Package Compare versions

Comparing version 2.3.3 to 2.4.0

23

dist/index.d.ts

@@ -11,2 +11,3 @@ /// <reference types="node" />

binary?: boolean;
timeout?: number;
}

@@ -38,2 +39,8 @@ export interface BroadcastOptions {

/**
* Returns the number of Socket.IO servers in the cluster
*
* @public
*/
serverCount(): Promise<number>;
/**
* Adds a socket to a list of room.

@@ -74,2 +81,18 @@ *

/**
* Broadcasts a packet and expects multiple acknowledgements.
*
* Options:
* - `flags` {Object} flags for this packet
* - `except` {Array} sids that should be excluded
* - `rooms` {Array} list of rooms to broadcast to
*
* @param {Object} packet the packet object
* @param {Object} opts the options
* @param clientCountCallback - the number of clients that received the packet
* @param ack - the callback that will be called for each client response
*
* @public
*/
broadcastWithAck(packet: any, opts: BroadcastOptions, clientCountCallback: (clientCount: number) => void, ack: (...args: any[]) => void): void;
/**
* Gets a list of sockets by sid.

@@ -76,0 +99,0 @@ *

52

dist/index.js

@@ -27,2 +27,10 @@ "use strict";

/**
* Returns the number of Socket.IO servers in the cluster
*
* @public
*/
serverCount() {
return Promise.resolve(1);
}
/**
* Adds a socket to a list of room.

@@ -110,2 +118,5 @@ *

this.apply(opts, socket => {
if (typeof socket.notifyOutgoingListeners === "function") {
socket.notifyOutgoingListeners(packet);
}
socket.client.writeToEngine(encodedPackets, packetOpts);

@@ -115,2 +126,41 @@ });

/**
* Broadcasts a packet and expects multiple acknowledgements.
*
* Options:
* - `flags` {Object} flags for this packet
* - `except` {Array} sids that should be excluded
* - `rooms` {Array} list of rooms to broadcast to
*
* @param {Object} packet the packet object
* @param {Object} opts the options
* @param clientCountCallback - the number of clients that received the packet
* @param ack - the callback that will be called for each client response
*
* @public
*/
broadcastWithAck(packet, opts, clientCountCallback, ack) {
const flags = opts.flags || {};
const packetOpts = {
preEncoded: true,
volatile: flags.volatile,
compress: flags.compress
};
packet.nsp = this.nsp.name;
// we can use the same id for each packet, since the _ids counter is common (no duplicate)
packet.id = this.nsp._ids++;
const encodedPackets = this.encoder.encode(packet);
let clientCount = 0;
this.apply(opts, socket => {
// track the total number of acknowledgements that are expected
clientCount++;
// call the ack callback for each client response
socket.acks.set(packet.id, ack);
if (typeof socket.notifyOutgoingListeners === "function") {
socket.notifyOutgoingListeners(packet);
}
socket.client.writeToEngine(encodedPackets, packetOpts);
});
clientCountCallback(clientCount);
}
/**
* Gets a list of sockets by sid.

@@ -225,5 +275,5 @@ *

serverSideEmit(packet) {
throw new Error("this adapter does not support the serverSideEmit() functionality");
console.warn("this adapter does not support the serverSideEmit() functionality");
}
}
exports.Adapter = Adapter;

2

package.json
{
"name": "socket.io-adapter",
"version": "2.3.3",
"version": "2.4.0",
"license": "MIT",

@@ -5,0 +5,0 @@ "repository": {

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