Skip to content

Commit

Permalink
updating many dependencies to newer version, code changes required fo…
Browse files Browse the repository at this point in the history
…r socket.io upgrade
  • Loading branch information
btouellette committed Jun 24, 2014
1 parent 3b46d04 commit bd4c7b2
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 24 deletions.
18 changes: 9 additions & 9 deletions app/gameserver.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ var User = require('./models/user');

//TODO: matchmaking
//TODO: demo mode
//TODO: make sure updates to empty games or users don't crash the nodejs instance
//TODO: send update when players see game finish, when all have seen delete from db
//TODO: send error messages back to client if failure and report them back
//TODO: make sure that all items (current game, friends, etc) are kept in sync, consider just sending user and updating every time the user changes
Expand Down Expand Up @@ -42,27 +41,28 @@ module.exports = function(server, sessionStore) {
});

var io = require('socket.io').listen(server);
io.set('log level', 1); // reduce logging
io.set('authorization', function(handshakeData, accept) {
// validate session cookie and populate session id if given
io.use(function(socket, next) {
var handshakeData = socket.handshake;
if(handshakeData.headers.cookie) {
try {
handshakeData.cookie = cookie.parse(decodeURIComponent(handshakeData.headers.cookie));
if(!handshakeData.cookie['express.sid']) {
return accept('No session ID in parsed cookie', false);
next(new Error('No session ID in parsed cookie'));
}
handshakeData.sessionID = connect.utils.parseSignedCookie(handshakeData.cookie['express.sid'], process.env.EXPRESS_SESSION_SECRET);
if (handshakeData.cookie['express.sid'] == handshakeData.sessionID) {
return accept('Cookie is invalid.', false);
next(new Error('Cookie is invalid'));
}
} catch (err) {
return accept('Error parsing session cookie', false);
next(new Error('Error parsing session cookie'));
}
} else {
return accept('No cookie transmitted.', false);
next(new Error('No cookie transmitted'));
}
accept(null, true);
next();
});

// for each new connection get the session and set up server callbacks
io.sockets.on('connection', function (socket) {
// retrieve user information for user specific actions
sessionStore.get(socket.handshake.sessionID, function(err, session) {
Expand Down
28 changes: 14 additions & 14 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
{
"name": "node-authentication",
"name": "concarneau",
"main": "server.js",
"dependencies": {
"express": "~3.4.4",
"ejs": "~0.8.5",
"mongoose": "~3.8.1",
"passport": "~0.1.17",
"passport-local": "~0.1.6",
"passport-facebook": "~1.0.2",
"express": "~3.4.8",
"ejs": "~1.0.0",
"mongoose": "~3.8.12",
"passport": "~0.2.0",
"passport-local": "~1.0.0",
"passport-facebook": "~1.0.3",
"passport-twitter": "~1.0.2",
"passport-google-oauth": "~0.1.5",
"connect-flash": "~0.1.1",
"bcrypt-nodejs": "latest",
"tunnel": "0.0.3",
"socket.io": "^0.9.16",
"yargs": "~1.2.1",
"cookie": "~0.1.1",
"connect": "~2.14.3",
"socket.io": "~1.0.4",
"yargs": "~1.2.6",
"cookie": "~0.1.2",
"connect": "~2.14.5",
"q": "~1.0.1",
"moniker": "~0.1.2",
"connect-mongo": "~0.4.0",
"connect-mongo": "~0.4.1",
"nodetime": "~0.8.15",
"newrelic": "~1.5.2",
"nodemailer": "~0.6.5",
"newrelic": "~1.7.3",
"nodemailer": "~0.7.0",
"twit": "~1.1.15"
}
}
2 changes: 1 addition & 1 deletion views/game.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@
</div>
</div>
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/socket.io/0.9.16/socket.io.min.js"></script>
<script src="https://cdn.socket.io/socket.io-1.0.6.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/d3/3.4.5/d3.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/qtip2/2.2.0/jquery.qtip.min.js"></script>
<script>
Expand Down

0 comments on commit bd4c7b2

Please sign in to comment.