amirrajan / nodejs-against-humanity

Cards Against Humanity implemented using NodeJS
Other
7 stars 7 forks source link

Crash in gameViewModel when gameId is an array #2

Closed christothes closed 10 years ago

christothes commented 10 years ago

When responding to the connectToGame event, the socketIO packet parses the gameId and playerId values as single member arrays.

When gameId is passed to getGame as an array, I was seeing a crash in gameViewModel because the return value was undefined and was being passed to JSON.stringify.

The changes below send gameId as a single value as getGame expects in this scenario. I also just added an error check so that if the _.find still does return undefined for some reason, it will result in an empty object instead of undefined to avoid a crash of the node server.

christothes commented 10 years ago

rolling in some additional changes to a new PR and closing this one.

amirrajan commented 10 years ago

Cool.