Skip to content

Commit

Permalink
aggiunto setHeader, canale alertTecnico (con log in console)
Browse files Browse the repository at this point in the history
  • Loading branch information
mikosh75 committed Oct 20, 2011
1 parent 2058f55 commit 61f2c69
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 26 deletions.
25 changes: 0 additions & 25 deletions public/client.html

This file was deleted.

24 changes: 23 additions & 1 deletion server.js
Expand Up @@ -9,10 +9,18 @@ var bayeux = new faye.NodeAdapter({

var app = express.createServer();

setHeaders = function (req,res,next) {
res.header("X-Powered-By","nodejs");
res.header("Access-Control-Allow-Origin",req.header('origin'));
res.header("Access-Control-Allow-Headers", "X-Requested-With");
next();
}

app.configure(function(){
//app.use(express.logger({ format: ':method :url' }));
app.use(express.bodyParser());
app.use(express.methodOverride());
app.use(setHeaders);
app.use(app.router);
});

Expand All @@ -37,6 +45,15 @@ app.post('/message', function(req, res) {
res.send(200);
});

app.post('/alert_tecnico', function(req, res) {
bayeux.getClient().publish('/channel/' + req.body.ch, { id_chat : req.body.id_chat,
ch: req.body.ch
}
);
res.send(200);
});


app.get('/', function(req, res){
res.send('hello world');
});
Expand All @@ -50,5 +67,10 @@ app.listen(Number(port));

console.log('Listening on port ' + port );
bayeux.getClient().subscribe('/channel/*', function(message) {
console.log(message.timestamp + ' [' + message.ch + '] ' + message.clientid + ' ' + message.text);
if (message.ch=="T3"){
var ts = (new Date()).getTime();
console.log(ts + ' [' + message.ch + '] ' + message.id_chat);
} else {
console.log(message.timestamp + ' [' + message.ch + '] ' + message.clientid + ' ' + message.text);
}
});

0 comments on commit 61f2c69

Please sign in to comment.