var subscribeConversation = function() {
swampdragon.subscribe('chat', 1, {chat_id: 1}, function (context, data) {
// any thing that happens after successfully subscribing
console.log(context, data);
if (!firstRun) {
swampdragon.getPagedList('chat', {chat_id: 1}, 1, function (context, data) {
data.reverse().forEach(function(item){
addMessage(item.author, item.message);
})
}, function (context, data) {
console.error(data);
});
firstRun = true;
}
}, function (context, data) {
// anything that happens if subscribing failed
console.log(context, data);
});
}
swampdragon.open(function(){
addMessage('SYSTEM', '----- Connection OPEN --------------------------------------');
subscribeConversation();
});
swampdragon.close(function(){
addMessage('SYSTEM', '----- Connection LOST --------------------------------------');
});
swampdragon.onChannelMessage(function(chanel, data) {
console.log('New channel message');
addMessage(data.data.author, data.data.message);
console.log(data);
});
With two browsers open, when I first load the page there is no problem, but if I close and open the socket sometimes one or both clients dont reconnect to it.
I have a very basic setup for a PoC:
With two browsers open, when I first load the page there is no problem, but if I close and open the socket sometimes one or both clients dont reconnect to it.