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

ws-events-and-middlewares

Package Overview
Dependencies
Maintainers
1
Versions
27
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ws-events-and-middlewares - npm Package Compare versions

Comparing version 1.0.13 to 1.0.14

24

index.js

@@ -78,3 +78,3 @@ const Emitter = require('component-emitter')

function onclose (event) {
if (clients[sock.id]) delete clients[sock.id]
delete clients[sock.id]
listeners.emit('close', event)

@@ -117,3 +117,2 @@ }

function join (room) {
console.log(`[ws-events] join: ${room}`)
if (!Array.isArray(rooms[room])) {

@@ -126,3 +125,2 @@ rooms[room] = []

function leave (room) {
console.log(`[ws-events] leave: ${room}`)
if (!Array.isArray(rooms[room])) {

@@ -139,3 +137,2 @@ return

function leaveAll () {
console.log(`[ws-events] leaveAll`)
Object.keys(rooms).map(room => {

@@ -154,6 +151,3 @@ const index = rooms[room].indexOf(sock.id)

if (!Array.isArray(rooms[room])) { return }
rooms[room].map(socketId => {
console.log('Emitiendo mensaje el socket ' + socketId + ' por estar en la sala ' + room)
clients[socketId].emit.apply(clients[socketId], args)
})
rooms[room].map(socketId => clients[socketId].emit.apply(clients[socketId], args))
}

@@ -163,2 +157,11 @@ }

function toAll () {
return {
emit: function () {
const args = Array.from(arguments)
Object.keys(clients).map(socketId => clients[socketId].emit.apply(clients[socketId], args) )
}
}
}
var events = Object.create(sock)

@@ -174,9 +177,8 @@ events.emit = emit

events.to = to
events.toAll = toAll
// Guardamos el nuevo cliente
// Guardamos el nuevo cliente
clients[sock.id] = events
console.log('Nuevo cliente conectado:')
console.log(JSON.stringify(clients))
return events
}
{
"name": "ws-events-and-middlewares",
"version": "1.0.13",
"version": "1.0.14",
"description": "ws module wrapper to provide events",

@@ -5,0 +5,0 @@ "main": "index.js",

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