I'm using LS client in ionic 1 application. I have developed the mobile application using ionic 1. I have initialized the LS connection in every controller. Totally I have 3 tabs and whenever navigate to tabs every time connection getting initialize and If I navigate over the tabs more than 3 times my LS status object showing like disconnected and connection. Showing these 2 status continuously. I have the below code
Code:
$scope.setupLightstreamer = function() {
var protocolToUse = document.location.protocol != "file:" ? document.location.protocol : "http:";
var portToUse = document.location.protocol == "https:" ? "443" : "8080";
var lsClient = new Lightstreamer.LightstreamerClient(protocolToUse+"//myhost:"+portToUse,"MVBSTOCKLIST_REMOTE");
lsClient.addListener({
onStatusChange: function(newStatus) {
console.log(newStatus);
}
});
lsClient.connect();
}
So every time I click on tabs and navigate this code getting execute and creating new instance. So many connection lives on this and getting issue it seems.
And also I have tried like creating single instance from service and checking whether instance available in controller , if else will create new instance else using old instance itself. But update not happening if I navigate over the tabs more than 3 times. could you please help anyone to solve this issue.
Bookmarks