Re: [nodejs] Websockets on nodejs - Managing ws instances

2016-02-24 Thread Ray Jender
Got it. Now for some testing! Thanks again. Ray On Tuesday, February 23, 2016 at 11:01:23 PM UTC-5, Christopher Mina wrote: > > You're welcome. > > As a hint, you can look at this for managing the disconnects: > > ws.on('close', function close() { > numConnections--; > ... alert all

Re: [nodejs] Websockets on nodejs - Managing ws instances

2016-02-23 Thread Christopher Mina
You're welcome. As a hint, you can look at this for managing the disconnects: ws.on('close', function close() { numConnections--; ... alert all remaining sockets ... }); Best of luck. Chris On Tuesday, February 23, 2016 at 7:30:27 PM UTC-7, Ray Jender wrote: > > Well, with your help, I

Re: [nodejs] Websockets on nodejs - Managing ws instances

2016-02-23 Thread Ray Jender
Well, with your help, I now have it half working! It is updating each webpage for new connections. Now I have to figure out how to decrement when a user leaves. I will work on that and let you know. I really appreciate your help with this. You helped a blind man see! Ray On Monday,

Re: [nodejs] Websockets on nodejs - Managing ws instances

2016-02-22 Thread Christopher Mina
Ok, I finally actually checked out your library to help you a litle bit more. It looks like your ws library on the server actually maintains a list of open / connected clients, so this is actually pretty trivial. You'll be able to do something like this: *wss.on('connection',

Re: [nodejs] Websockets on nodejs - Managing ws instances

2016-02-22 Thread Ray Jender
On the client side, I am expecting json? And I do not have a clientSocket.on? What I have is: ws.onmessage = function(message) { var parsedMessage = JSON.parse(message.data); console.info('Received message: ' + message.data); switch (parsedMessage.id) { There a few

Re: [nodejs] Websockets on nodejs - Managing ws instances

2016-02-22 Thread Ray Jender
Getting close. Please see my previous post. Ray On Monday, February 22, 2016 at 6:34:14 PM UTC-5, Christopher Mina wrote: > > That's correct, just a normal array. > > I was just showing an example of how to use the array to store a reference > to all open web sockets. Then when you need to

Re: [nodejs] Websockets on nodejs - Managing ws instances

2016-02-22 Thread Christopher Mina
That's correct, just a normal array. I was just showing an example of how to use the array to store a reference to all open web sockets. Then when you need to increment, you'd just iterate over the array. e.g. var myCount = 10; sockets.forEach(function(ws) { ws.emit("countupdated",

Re: [nodejs] Websockets on nodejs - Managing ws instances

2016-02-22 Thread Sávio Lucena
Hey Ray, I haven’t been following this thread but from what I can infer of Chris’s answer ’sockets’ is a javascript Array to store and keep reference of each ws instance created, ‘push’ is just adding an instance to it :). > On Feb 22, 2016, at 2:00 PM, Ray Jender

[nodejs] Websockets on nodejs - Managing ws instances

2016-02-20 Thread Ray Jender
Please bear with me as I am new to websockets. So, my problem is keeping track of websocket instances. I am trying to modify some existing open source javascript code. I have server.js, index.js and index.html files. As with any website, it could have many users browsing the page. There is only