pketh / metome

Your personal diary service
http://pketh.org/Metome-Journal
MIT License
2 stars 0 forks source link

Update entry thumb with new upload #12

Open pketh opened 10 years ago

pketh commented 10 years ago

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.

pketh commented 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' });
pketh commented 10 years ago
  io.sockets.socket(< session id>).send('my message')
  io.sockets.socket(< session id>).emit('event name'[, arguments])
pketh commented 10 years ago

based on : https://gist.github.com/bobbydavid/2640463 shortcut = use https://github.com/wcamarao/session.socket.io

pketh commented 10 years ago

session.socket.io uses deprecated cookieparser , probably better to roll my own based on npm cookies and the gist example above

pketh commented 10 years ago

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)

pketh commented 10 years ago

examples : https://github.com/jaredhanson/passport-local/tree/master/examples/login

pketh commented 10 years ago

dependant on prerequisite: https://github.com/pketh/Metome/issues/28