Socket.IO – how do I get a list of connected sockets/clients?

I’m trying to get a list of all the sockets/clients that are currently connected. io.sockets does not return an array, unfortunately. I know I could keep my own list using an array, but don’t think this is an optimal solution for 2 reasons: Redundancy. Socket.IO already keeps a copy of this list. Socket.IO provides method … Read more

node.js TypeError: path must be absolute or specify root to res.sendFile [failed to parse JSON]

[add] So my next problem is that when i try adding a new dependence (npm install –save socket.io). The JSON file is also valid. I get this error: Failed to parse json npm ERR! Unexpected string npm ERR! File: /Users/John/package.json npm ERR! Failed to parse package.json data. npm ERR! package.json must be actual JSON, not … Read more

Good beginners tutorial to socket.io? [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for … Read more

Send message to specific client with socket.io and node.js

I’m working with socket.io and node.js and until now it seems pretty good, but I don’t know how to send a message from the server to an specific client, something like this: client.send(message, receiverSessionId) But neither the .send() nor the .broadcast() methods seem to supply my need. What I have found as a possible solution, … Read more

Send response to all clients except sender

To send something to all clients, you use: io.sockets.emit(‘response’, data); To receive from clients, you use: socket.on(‘cursor’, function(data) { … }); How can I combine the two so that when recieving a message on the server from a client, I send that message to all users except the one sending the message? socket.on(‘cursor’, function(data) { … Read more

Which websocket library to use with Node.js? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers. Want to improve this question? Update the question so it’s on-topic for Stack Overflow. Closed 5 years ago. Improve this question Currently there is a plethora of websocket libraries for node.js, the most popular seem to be: https://github.com/Worlize/WebSocket-Node https://github.com/einaros/ws https://github.com/LearnBoost/engine.io … Read more

Differences between socket.io and websockets

What are the differences between socket.io and websockets in node.js? Are they both server push technologies? The only differences I felt was, socket.io allowed me to send/emit messages by specifying an event name. In the case of socket.io a message from server will reach on all clients, but for the same in websockets I was … Read more