upgrade socket.io and express.js

required some retooling of how everything is setup
This commit is contained in:
ali asaria 2014-08-17 13:36:34 -04:00
parent 08f86a0566
commit 8f2863f86e
4 changed files with 72 additions and 100 deletions

View file

@ -17,7 +17,7 @@
"async": "~0.9.0",
"redis": "~0.12.1",
"sanitizer": "~0.1.1",
"socket.io": "0.8.x",
"socket.io": "1.x",
"simplesets": "~1.2.0",
"express": "4.x",
"jade": "~1.5.0"

View file

@ -20,31 +20,15 @@ var data = require('./lib/data.js').db;
var sids_to_user_names = [];
/**************
SETUP
SETUP EXPRESS
**************/
var app = express();
app.configure( function(){
app.use(express.static(__dirname + '/client'));
app.use(express.bodyParser());
//app.use(express.cookieParser());
//Cookies are not really needed... but may be in the future?
app.use(express.cookieParser());
app.use(
express.session({
key: "scrumscrum-cookie",
secret: "kookoorikoo",
// store: session_store,
cookie: { path: '/', httpOnly: true, maxAge: 14400000 }
})
);
});
app.listen(process.argv[2] || 8124);
var server = require('http').Server(app);
server.listen(process.argv[2] || 8080);
//app.listen(process.argv[2] || 8080);
/**************
ROUTES
@ -53,21 +37,21 @@ app.get('/', function(req, res) {
//console.log(req.header('host'));
url = req.header('host');
res.render('home.jade', {
layout: false,
locals: {url: url}
url: url
});
});
app.get('/demo', function(req, res) {
res.render('index.jade', {
locals: {pageTitle: 'scrumblr - demo', demo: true}
pageTitle: 'scrumblr - demo',
demo: true
});
});
app.get('/:id', function(req, res){
res.render('index.jade', {
locals: {pageTitle: ('scrumblr - ' + req.params.id) }
pageTitle: ('scrumblr - ' + req.params.id)
});
});
@ -75,24 +59,8 @@ app.get('/:id', function(req, res){
/**************
SOCKET.I0
**************/
//I limit the number of potential transports because xhr was causing trouble
//with frequent disconnects
var socketio_options = {
transports: ['websocket', 'flashsocket', 'htmlfile', 'jsonp-polling']
};
// socket.io SETUP
var io = require('socket.io').listen(app);
io.configure(function () {
io.set('transports', [
'websocket'
, 'flashsocket'
, 'htmlfile'
// , 'xhr-polling'
, 'jsonp-polling'
]);
var io = require('socket.io')(server);
io.set('log level', 1);
});
io.sockets.on('connection', function (client) {
//santizes text
function scrub( text ) {

View file

@ -1,3 +1,6 @@
extends layout
block body
- if (locals.demo)
div.notice-bar this is a demo board. to make a private board, go to <a href="http://scrumblr.ca">scrumblr.ca</a>

View file

@ -27,4 +27,5 @@ html(lang="en")
title= locals.pageTitle
body!= body
body
block body