Open pketh opened 10 years ago
apparently within an app.post , sockets won’t fire unless they have a session id passed to them.
from : https://groups.google.com/forum/#!topic/socket_io/NQNQpGobXEQ While the server receives a connect emit from the client, send the socket.id as an emit from the server. Save it client side and pass it when you POST, as a hidden variable perhaps
http://www.danielbaulig.de/socket-ioexpress/ has a fuller walkthrough , but it’s session id syntax is outdated . ie..
// v0.6.x
socket.clients[sid].send({ a: 'b' });
// v0.7.x
io.sockets.sockets[sid].json.send({ a: 'b' });
io.sockets.socket(< session id>).send('my message')
io.sockets.socket(< session id>).emit('event name'[, arguments])
based on : https://gist.github.com/bobbydavid/2640463 shortcut = use https://github.com/wcamarao/session.socket.io
session.socket.io uses deprecated cookieparser , probably better to roll my own based on npm cookies and the gist example above
going forward using passport for auth (later will add bycrpt on pwds). Passport is popular, well maintained and has easy drop in strategies to connect using twitter, dropbox , etc. if I want to do that in the future. http://stackoverflow.com/questions/13095418/how-to-use-passport-with-express-and-socket-io
(also using cookie to replace cookieparser)
dependant on prerequisite: https://github.com/pketh/Metome/issues/28
the thumb should enter on socket thumbsuccess message passed to client. Currently not working properly.
need to isolate (using dev tools) whether it's the server not firing or the client not registering. Then … profit time.