samedi 29 mars 2014

Express.IO : Emitting to specific client from non-io route?


Vote count:

0




The only io route I have at the moment is to receive a ready message from clients when they first connect...



//ADD USER TO THEIR OWN ROOM FOR NOTIFICATIONS
app.io.route('ready', function(req) {
console.log('~~~~~~~~~~~~~ IO READY ~~~~~~~~~~~~~');
req.io.join('U-'+req.session.passport.user); //i.e. - 'U-154040'
req.io.emit('welcome', {test:true});
});


Emitting on the request back to the client (naturally) works just fine. However, in an Express non-io route (of which I have many) I'd like to be able to emit to specific users via the room...



//EXPRESS ROUTE'S MIDDLEWARE CONTROLLER
var express = require('express.io'),
app = express().http().io();

module.exports = {
doSomething: function(req, res) {
app.io.room('U-154040').broadcast('notification', {});
res.send(200);
}
};


... This does not produce an error, but the message is not received by the targeted client/room. Is this just not possible?



asked 1 min ago

E-Madd

1,326





Aucun commentaire:

Enregistrer un commentaire