-
March 12th, 2019, 02:39 PM
#1
How send information to stream by session or username
Hi guys. I really need your help)
I have an order data adapter on Node.js.
How can I filter information for stream by userName or sessionId from Lighstreamer Session?
For example: we have couple connections: user1, user2.
I have private info for user1, but not for user2.
I understand that metadata provider can help me, but how?
Looking forward to your reply.
-
March 12th, 2019, 04:42 PM
#2
Hi patrol90,
You can leverage the getItems function (please refer to the Java API where the description is a little more expanded: https://lightstreamer.com/docs/adapt...a.lang.String-).
The trick is that all the clients subscribe to the same Item, for example my_item, but your implementation of this method will return a different item name decorated with the user name or some other unique id for user or session.
For example the method will return my_item_user1 and my_item_user2 respectively.
Then your data adapter will handle these customized items, in order to send private messages to specific user.
Please note that if you have mixed private and broadcast messages the getItems could return two Items one dedicated to the User and one public (ie. my_item_userX and my_item_public).
Please let me know if you need any further clarifications.
Regards,
Giuseppe
-
March 13th, 2019, 02:27 PM
#3
Hi Giuseppe.
Great thanks!
Works fine, great advice. First read I was confused, how I should return it, I tried with "return", after that I understood.
Maybe my code will help somebody.
this.metadataProvider.on('getItems', function(user, response) {
response.success([`${itemName}_${user.userName}`]);
});
-
March 13th, 2019, 04:11 PM
#4
Hi patrol90,
Thank you for sharing your code.
Regards,
Giuseppe
Similar Threads
-
By stephenallred in forum Client SDKs
Replies: 1
Last Post: June 7th, 2010, 11:13 AM
-
By naitsir in forum Client SDKs
Replies: 9
Last Post: October 19th, 2009, 04:02 PM
-
By kanibal210 in forum Client SDKs
Replies: 1
Last Post: September 30th, 2009, 08:36 AM
-
By EWANG in forum Adapter SDKs
Replies: 1
Last Post: April 29th, 2009, 08:38 AM
-
By markgoldin in forum General
Replies: 16
Last Post: August 6th, 2008, 10:00 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 04:38 PM.
Bookmarks