Merge branch 'jghaines-master'

This commit is contained in:
José F. Romaniello 2016-06-21 09:41:31 -03:00
commit e78e376480
2 changed files with 19 additions and 10 deletions

View File

@ -11,6 +11,7 @@ var env = {
AUTH0_CLIENT_ID: process.env.AUTH0_CLIENT_ID,
AUTH0_DOMAIN: process.env.AUTH0_DOMAIN
};
var port = process.env.PORT || 3001;
app.set('views', __dirname + '/views');
app.set('view engine', 'pug');
@ -34,6 +35,7 @@ app.get('/', function (req, res) {
res.render('index', { env: env });
});
http.listen(3001, function(){
console.log('listening on *:3001');
http.listen(port, function(){
console.log('listening on *:' + port);
});

View File

@ -46,8 +46,12 @@ block content
function openChat() {
var socket = io();
socket.on('connect', function () {
socket.on('authenticated', function () {
socket
.on('connect', function (msg) {
console.log("connected");
socket.emit('authenticate', {token: userToken}); // send the jwt
})
.on('authenticated', function () {
//Do
$('#login').hide();
$('#chat').show();
@ -56,10 +60,13 @@ block content
$('#m').val('');
return false;
});
socket.on('chat message', function (msg) {
})
.on('unauthorized', function(msg){
console.log("unauthorized: " + JSON.stringify(msg.data));
throw new Error(msg.data.type);
})
.on('chat message', function (msg) {
console.log("msg");
$('#messages').append($('<li>').text(msg));
});
}).emit('authenticate', {token: userToken}); // send the jwt
})
};