upgrade socket.io and express.js
required some retooling of how everything is setup
This commit is contained in:
parent
08f86a0566
commit
8f2863f86e
4 changed files with 72 additions and 100 deletions
|
@ -17,7 +17,7 @@
|
||||||
"async": "~0.9.0",
|
"async": "~0.9.0",
|
||||||
"redis": "~0.12.1",
|
"redis": "~0.12.1",
|
||||||
"sanitizer": "~0.1.1",
|
"sanitizer": "~0.1.1",
|
||||||
"socket.io": "0.8.x",
|
"socket.io": "1.x",
|
||||||
"simplesets": "~1.2.0",
|
"simplesets": "~1.2.0",
|
||||||
"express": "4.x",
|
"express": "4.x",
|
||||||
"jade": "~1.5.0"
|
"jade": "~1.5.0"
|
||||||
|
|
52
server.js
52
server.js
|
@ -20,31 +20,15 @@ var data = require('./lib/data.js').db;
|
||||||
var sids_to_user_names = [];
|
var sids_to_user_names = [];
|
||||||
|
|
||||||
/**************
|
/**************
|
||||||
SETUP
|
SETUP EXPRESS
|
||||||
**************/
|
**************/
|
||||||
var app = express();
|
var app = express();
|
||||||
|
|
||||||
app.configure( function(){
|
|
||||||
app.use(express.static(__dirname + '/client'));
|
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
|
ROUTES
|
||||||
|
@ -53,21 +37,21 @@ app.get('/', function(req, res) {
|
||||||
//console.log(req.header('host'));
|
//console.log(req.header('host'));
|
||||||
url = req.header('host');
|
url = req.header('host');
|
||||||
res.render('home.jade', {
|
res.render('home.jade', {
|
||||||
layout: false,
|
url: url
|
||||||
locals: {url: url}
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
app.get('/demo', function(req, res) {
|
app.get('/demo', function(req, res) {
|
||||||
res.render('index.jade', {
|
res.render('index.jade', {
|
||||||
locals: {pageTitle: 'scrumblr - demo', demo: true}
|
pageTitle: 'scrumblr - demo',
|
||||||
|
demo: true
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
app.get('/:id', function(req, res){
|
app.get('/:id', function(req, res){
|
||||||
|
|
||||||
res.render('index.jade', {
|
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
|
SOCKET.I0
|
||||||
**************/
|
**************/
|
||||||
//I limit the number of potential transports because xhr was causing trouble
|
var io = require('socket.io')(server);
|
||||||
//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'
|
|
||||||
]);
|
|
||||||
|
|
||||||
io.set('log level', 1);
|
|
||||||
});
|
|
||||||
io.sockets.on('connection', function (client) {
|
io.sockets.on('connection', function (client) {
|
||||||
//santizes text
|
//santizes text
|
||||||
function scrub( text ) {
|
function scrub( text ) {
|
||||||
|
|
|
@ -1,3 +1,6 @@
|
||||||
|
extends layout
|
||||||
|
|
||||||
|
block body
|
||||||
- if (locals.demo)
|
- 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>
|
div.notice-bar this is a demo board. to make a private board, go to <a href="http://scrumblr.ca">scrumblr.ca</a>
|
||||||
|
|
||||||
|
|
|
@ -27,4 +27,5 @@ html(lang="en")
|
||||||
|
|
||||||
title= locals.pageTitle
|
title= locals.pageTitle
|
||||||
|
|
||||||
body!= body
|
body
|
||||||
|
block body
|
||||||
|
|
Loading…
Add table
Reference in a new issue