Skip to content

Commit

Permalink
Adding socket stuff, still need to add the js.
Browse files Browse the repository at this point in the history
  • Loading branch information
MrMaksimize committed Feb 21, 2014
1 parent 48ecd33 commit 2f8669b
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
21 changes: 20 additions & 1 deletion app.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,11 @@ var passportConf = require('./config/passport');
* Create Express server.
*/

//var app = express();
var app = express();
var http = require('http');
var server = http.createServer(app);
var io = require('socket.io').listen(server);

/**
* Mongoose configuration.
Expand Down Expand Up @@ -169,6 +173,21 @@ app.get('/auth/venmo/callback', passport.authorize('venmo', { failureRedirect: '
* Start Express server.
*/

app.listen(app.get('port'), function() {
//app.listen(app.get('port'), function() {
server.listen(app.get('port'), function() {
console.log("✔ Express server listening on port %d in %s mode", app.get('port'), app.settings.env);
});

io.configure(function() {
io.set('transports', ['websocket']);
});

io.sockets.on('connection', function(socket) {
socket.emit('greet', { hello: 'Hey, Mr.Client!' });
socket.on('respond', function(data) {
console.log(data);
});
socket.on('disconnect', function() {
console.log('Socket disconnected');
});
});
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
"connect-mongo": "~0.4.0",
"twilio": "~1.5.0",
"validator": "~3.2.1",
"crypto": "0.0.3"
"crypto": "0.0.3",
"socket.io": "~0.9.16"
}
}

0 comments on commit 2f8669b

Please sign in to comment.