-
November 23rd, 2020, 11:42 PM
#1
Hi, this is pretty much what I am doing, unfortunately I can't test it out with the Demo sample, but if you can take a look and let me know if this seems straightforward to you would be helpful! The reason I am following this approach is to not duplicate so much code.
varls = require('lightstreamer-client-node');
constconnect = (url, adapter) => {
const lsClient = new ls.LightstreamerClient(url, adapter);
lsClient.addListener({
onStatusChange: (newStatus) => {
console.log(newStatus)
},
});
lsClient.connect();
return lsClient;
};
var myClient1 = connect("https://push.lightstreamer1.com","WELCOME");
var myClient2 = connect("https://push.lightstreamer2.com", "WELCOME")
const lsSubscribe = (lsClient) => {
var mySubscription = new ls.Subscription("MERGE",["item1","item2","item3"],["stock_name","last_price"]);
mySubscription.setDataAdapter("STOCKS");
mySubscription.setRequestedSnapshot("yes");
mySubscription.addListener({
onSubscription: function() {
console.log("SUBSCRIBED");
},
onUnsubscription: function() {
console.log("UNSUBSCRIBED");
},
onItemUpdate: function(obj) {
console.log("Fst - " + obj.getValue("stock_name") + ": " + obj.getValue("last_price"));
}
});
lsClient.subscribe(mySubscription);
};
lsSubscribe(myClient1)
lsSubscribe(myClient2)
Last edited by sdi0900; November 23rd, 2020 at 11:49 PM.
Similar Threads
-
By sjohn in forum Client SDKs
Replies: 11
Last Post: January 23rd, 2015, 11:22 AM
-
By pluczak in forum Adapter SDKs
Replies: 1
Last Post: April 26th, 2012, 10:50 AM
-
By wwatts in forum Client SDKs
Replies: 4
Last Post: February 16th, 2010, 08:58 AM
-
By sarbao in forum Adapter SDKs
Replies: 1
Last Post: April 20th, 2009, 09:29 AM
-
By Sinead in forum Client SDKs
Replies: 3
Last Post: February 8th, 2007, 09:11 AM
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
All times are GMT +1. The time now is 12:26 PM.
Bookmarks