Reputation: 645
Is it possible for the server to do a socket.send on page request?
so it any client that request a certain page the server side can send a post message to all clients.
so when a web request comes into a page called "status". i want the server code to parse the querystring and broadcast, but i'm unable to get the io object in my app.js to do so.
var url = require('url');
exports.update = function(req, res){
var url_parts = url.parse(req.url, true);
var query = url_parts.query;
// here i want to broadcast the query string query.update
res.render('status', { status: query.update });
};
Upvotes: 0
Views: 35
Reputation: 2112
Did you try something like:
app.get('/', function (req, res) {
io.sockets.emit('your event name', {data: 'some data'});
});
Upvotes: 1