Node.js faye publish-subscribe messaging between web clients

Description

Node.js faye publish-subscribe messaging between web clients


console.log('Point your browser to http://localhost:8000/client.html');

var express = require('express'),
    faye = require('faye');

var bayeux = new faye.NodeAdapter({
  mount:    '/faye',
  timeout:  45/*from  ww w . j  a va2s.  c o m*/
});

var app = express.createServer();
app.configure(function () {
  app.use(express.bodyParser());
  app.use(express.static(__dirname + '/public'));
});

app.post('/message', function(req, res) {
  bayeux.getClient().publish('/channel', {text: req.body.message});
  res.send(200);
});

bayeux.attach(app);
app.listen(8000);



PreviousNext

Related