node-multi-socketservers
Advanced tools
Comparing version 0.2.10 to 0.2.11
@@ -176,3 +176,3 @@ "use strict"; | ||
emit (eventName, data) { | ||
emit (eventName, ...data) { | ||
@@ -200,7 +200,20 @@ return Promise.resolve().then(() => { | ||
if ("undefined" !== typeof data) { | ||
if ("undefined" === typeof data) { | ||
server.sockets.emit(eventName); | ||
} | ||
else if (!(data instanceof Array)) { | ||
server.sockets.emit(eventName, data); | ||
} | ||
else if (1 === data.length) { | ||
if ("undefined" === typeof data[0]) { | ||
server.sockets.emit(eventName); | ||
} | ||
else { | ||
server.sockets.emit(eventName, data[0]); | ||
} | ||
} | ||
else { | ||
server.sockets.emit(eventName); | ||
server.sockets.emit(eventName, ...data); | ||
} | ||
@@ -218,3 +231,3 @@ | ||
broadcast (socket, server, eventName, data) { | ||
broadcast (socket, server, eventName, ...data) { | ||
@@ -254,17 +267,46 @@ return Promise.resolve().then(() => { | ||
// other server | ||
if (_server.options.port !== server.options.port) { | ||
if ("undefined" !== typeof data) { | ||
if ("undefined" === typeof data) { | ||
_server.sockets.emit(eventName); | ||
} | ||
else if (!(data instanceof Array)) { | ||
_server.sockets.emit(eventName, data); | ||
} | ||
else if (1 === data.length) { | ||
if ("undefined" === typeof data[0]) { | ||
_server.sockets.emit(eventName); | ||
} | ||
else { | ||
_server.sockets.emit(eventName, data[0]); | ||
} | ||
} | ||
else { | ||
_server.sockets.emit(eventName); | ||
_server.sockets.emit(eventName, ...data); | ||
} | ||
} | ||
else if ("undefined" !== typeof data) { | ||
// same server | ||
else if ("undefined" === typeof data) { | ||
socket.broadcast.emit(eventName); | ||
} | ||
else if (!(data instanceof Array)) { | ||
socket.broadcast.emit(eventName, data); | ||
} | ||
else if (1 === data.length) { | ||
if ("undefined" === typeof data[0]) { | ||
socket.broadcast.emit(eventName); | ||
} | ||
else { | ||
socket.broadcast.emit(eventName, data[0]); | ||
} | ||
} | ||
else { | ||
socket.broadcast.emit(eventName); | ||
socket.broadcast.emit(eventName, ...data); | ||
} | ||
@@ -271,0 +313,0 @@ |
{ | ||
"name": "node-multi-socketservers", | ||
"version": "0.2.10", | ||
"version": "0.2.11", | ||
"description": "A multi http & socket servers manager, based on node-multi-webserver", | ||
@@ -5,0 +5,0 @@ "main": "lib/main.js", |
@@ -773,8 +773,8 @@ /* | ||
multiServers.broadcast(socket, server, "testwithdata", false).then(() => { | ||
return multiServers.broadcast(socket, server, "answer").then(() => { | ||
socket.disconnect(); | ||
}); | ||
multiServers.broadcast(socket, server, "testwithonedata", false).then(() => { | ||
return multiServers.broadcast(socket, server, "testwithmultipledata", false, true); | ||
}).then(() => { | ||
return multiServers.broadcast(socket, server, "answer"); | ||
}).then(() => { | ||
socket.disconnect(); | ||
}); | ||
@@ -781,0 +781,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
42715
1168