I have issue on connecting LS server in multiple page
(App developed my using Ionic Cordova platform.)
I have an application like trading platform. In my first page, I need to display all of the live rates(List of stocks and their rates). If they click on trade button I need to display only what every tradable stock. And If click on the stock from this I need to display responding stock details and Bid and Ask price and from this screen, users will submit their required quantity and submit the page. For every page currently, i'm opening the new connection.
var protocolToUse = document.location.protocol != "file:" ? document.location.protocol : "http:";
var portToUse = document.location.protocol == "https:" ? "443" : "8080";
var lsClient = new Lightstreamer.LightstreamerClient(protocolToUse+"//domain.com:"+portToUse,"STOCKLIST_REMOTE");
lsClient.connect();
As like that connecting in all of my three pages. But If I navigate the pages means connection getting close automatically. Showing the error like session terminated. Could you please help me anyone to fix this issue. Or else id there any other way to share the connection(connectionSharing) from one page to another page. I have tried like below code but issue happens. It says have to add connection sharing library.
lsClient.connectionSharing.enableSharing("CommonCo nnection", "ATTACH", "CREATE");
And also I need if we use connectionsharring means how to use that shared connection in another page.
I have below code in all of my three page controller(I'm using ionic framework for my android application )
var protocolToUse = document.location.protocol != "file:" ? document.location.protocol : "http:";
var portToUse = document.location.protocol == "https:" ? "443" : "8080";
var lsClient = new Lightstreamer.LightstreamerClient(protocolToUse+"//domain.com:"+portToUse,"STOCKLIST_REMOTE");
lsClient.connectionOptions.setHttpExtraHeaders({"u sername" : "bullion"});
lsClient.addListener({
onStatusChange: function(newStatus) {
console.log(newStatus);
}
});
lsClient.connect();