ptmccarthy / nodechat

A table-top game platform.
MIT License
2 stars 1 forks source link

Migrate to socket.io version 1.0 #27

Closed ptmccarthy closed 10 years ago

ptmccarthy commented 10 years ago

Looks like socket.io version 1.0 came out, and after I npm installed node crashes when attempting to join the chat.

info: Socket initiated by user test

TypeError: Cannot read property 'handshaken' of undefined
    at getUserFromSocket (/Users/pmccarthy/Documents/codez/dd_app/sockets.js:160:28)
    at onSubscribe (/Users/pmccarthy/Documents/codez/dd_app/sockets.js:44:14)
    at Socket.<anonymous> (/Users/pmccarthy/Documents/codez/dd_app/sockets.js:29:43)
    at Socket.EventEmitter.emit (events.js:95:17)
    at Socket.onevent (/Users/pmccarthy/Documents/codez/dd_app/node_modules/socket.io/lib/socket.js:321:8)
    at Socket.onpacket (/Users/pmccarthy/Documents/codez/dd_app/node_modules/socket.io/lib/socket.js:285:12)
    at Client.ondecoded (/Users/pmccarthy/Documents/codez/dd_app/node_modules/socket.io/lib/client.js:181:14)
    at Decoder.Emitter.emit (/Users/pmccarthy/Documents/codez/dd_app/node_modules/socket.io/node_modules/socket.io-parser/node_modules/emitter/index.js:132:20)
    at Decoder.add (/Users/pmccarthy/Documents/codez/dd_app/node_modules/socket.io/node_modules/socket.io-parser/index.js:224:12)
    at Client.ondata (/Users/pmccarthy/Documents/codez/dd_app/node_modules/socket.io/lib/client.js:166:16)
ptmccarthy commented 10 years ago

http://socket.io/blog/introducing-socket-io-1-0/

Checkout that multiplayer gameboy emulator running in node with socket.io though

ptmccarthy commented 10 years ago

https://github.com/Automattic/socket.io/wiki/Migrating-to-1.0

ghost commented 10 years ago

this is actually a good excuse to fix some hacky shit. That reference to 'handshaken' is because the user retrieved by passport is buried wayyyy the fuck inside the socket object (we have to call var user = socket.manager.handshaken[socket.id].user; to grab it). I bet that the socket 1.0 upgrade broke passport.socketio, but hopefully that will result in a more accessible user object

ptmccarthy commented 10 years ago

Looking at some migration stuff, it looks like socket.io itself might handle some of the stuff that passport-socket was created to deal with.