Reputation: 508
I used npm to install socket.io. The server is running fine but is not capturing custom emitted events from the client.
The documentation on socket.io is not up to date, for example the socket.io-node package does not exist in the npm repo like the git page says.
So I'm wondering if this functionality is gone in the base socket.io install or if I am doing something wrong.
My code is basically as follows:
server:
client.on('checkin', function (name) { ... });
client:
socket.emit('checkin',name);
Is there something more I need to be doing?
Upvotes: 4
Views: 3608
Reputation: 196
Socket.io 0.7 was released today (see this link), and the events used by @penguinbroker in it's example code are working now.
Upvotes: 1
Reputation: 17357
The docs on the repo were updated three days ago, changing the reference from 'socket.io' to 'socket.io-node', so it appears things are in flux.
To get the functionality you need, you might check out eventedsocket at https://github.com/torgeir/eventedsocket (npm install eventedsocket)
From the README.md:
Eventedsocket adds event like behavior to your socket.io connection, allowing for events to be sent from client(s) to server or server to client(s). Your custom events along with the desired data are communicated as json over whatever protocol socket.io might choose.
Upvotes: 1