You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I didn't know where to ask this, and cant find it in the README or exemple, so I try there.
Is it possible, using RabbitJS, to manage offline messages when a user disconnects ?
The aim is to use it for Android Application and SocketIO even if there are network loss.
Can you tell me how should I do that ?
Here's my code :
var context = require('rabbit.js').createContext();
var app = require('express')();
var server = require('http').Server(app);
var io = require('socket.io')(server);
app.get('/', function (req, res) {
res.sendfile(__dirname + '/index.html');
});
server.listen(8888);
io.sockets.on('connection', function (socket) {
var pub = context.socket('PUB');
var sub = context.socket('SUB');
sub.setEncoding('utf8');
pub.connect('q');
sub.connect('q');
socket.on('message', function (msg) {
pub.write(msg, 'utf8');
});
sub.on('data', function (msg) {
socket.emit('news', msg);
});
/* On ferme les streams lorsqu'on se deco */
socket.on('disconnect', function () {
pub.close();
sub.close();
});
});
The text was updated successfully, but these errors were encountered:
This is not really encouraged, by design -- PUB/SUB sockets are meant to only collect messages while your application is running.
You may find it easier to encode what you want in amqplib (squaremo/amqp.node), which has full control over the lifetime of exchanges and queues and so on, at the cost of having to do things at a "lower level".
I didn't know where to ask this, and cant find it in the README or exemple, so I try there.
Is it possible, using RabbitJS, to manage offline messages when a user disconnects ?
The aim is to use it for Android Application and SocketIO even if there are network loss.
Can you tell me how should I do that ?
Here's my code :
var context = require('rabbit.js').createContext();
var app = require('express')();
var server = require('http').Server(app);
var io = require('socket.io')(server);
app.get('/', function (req, res) {
res.sendfile(__dirname + '/index.html');
});
server.listen(8888);
io.sockets.on('connection', function (socket) {
var pub = context.socket('PUB');
var sub = context.socket('SUB');
sub.setEncoding('utf8');
pub.connect('q');
sub.connect('q');
});
The text was updated successfully, but these errors were encountered: