1
0
mirror of https://github.com/node-red/node-red.git synced 2023-10-10 13:36:53 +02:00

remove websocket node maxlistener warning

This commit is contained in:
Dave Conway-Jones 2016-09-23 23:36:58 +01:00
parent 69a0934173
commit ded1376957

View File

@ -37,6 +37,7 @@ module.exports = function(RED) {
function startconn() { // Connect to remote endpoint function startconn() { // Connect to remote endpoint
var socket = new ws(node.path); var socket = new ws(node.path);
socket.setMaxListeners(0);
node.server = socket; // keep for closing node.server = socket; // keep for closing
handleConnection(socket); handleConnection(socket);
} }
@ -95,7 +96,7 @@ module.exports = function(RED) {
// Workaround https://github.com/einaros/ws/pull/253 // Workaround https://github.com/einaros/ws/pull/253
// Stop listening for new listener events // Stop listening for new listener events
RED.server.removeListener('newListener',storeListener); RED.server.removeListener('newListener',storeListener);
node.server.setMaxListeners(0);
node.server.on('connection', handleConnection); node.server.on('connection', handleConnection);
} }
else { else {
@ -163,9 +164,10 @@ module.exports = function(RED) {
} }
WebSocketListenerNode.prototype.broadcast = function(data) { WebSocketListenerNode.prototype.broadcast = function(data) {
var i;
try { try {
if(this.isServer) { if (this.isServer) {
for (var i = 0; i < this.server.clients.length; i++) { for (i = 0; i < this.server.clients.length; i++) {
this.server.clients[i].send(data); this.server.clients[i].send(data);
} }
} }