Page 1 of 2 12 LastLast
Results 1 to 10 of 13
  1. #1
    Power Member
    Join Date
    Sep 2013
    Location
    Coimbatore
    Posts
    121

    How to bind dynamic data created in remote adapter in LS client

    I'm having below json data structure, this will update the dynamically. In this structure dynamically add or delete the stock rows.This data contains multiple clients data. Now I need to display connected clients data to users.For example if vb clients web page open means they need to get the data of vb clients data(
    Code:
    "vb":[{"com_id":"41","com_name":"GOLD - SALEM","selling_rate":"4977.00","buying_rate":"-","delivery":"25-06-2020","retail_rate":"-"},{"com_id":"38","com_name":"SILVER - SALEM","selling_rate":"49880.00","buying_rate":"-","delivery":"25-06-2020","retail_rate":"-"}]
    ). Whether the command update is possible using this type data structure or I need to change the structure


    Code:
    {"vb":[{"com_id":"41","com_name":"GOLD - SALEM","selling_rate":"4977.00","buying_rate":"-","delivery":"25-06-2020","retail_rate":"-"},{"com_id":"38","com_name":"SILVER - SALEM","selling_rate":"49880.00","buying_rate":"-","delivery":"25-06-2020","retail_rate":"-"}],"akumar":[{"com_id":"33","com_name":"GSUT999KG1","selling_rate":"48147","buying_rate":"48311","delivery":"25-06-2020","retail_rate":"-"},{"com_id":"37","com_name":"GAHD999KG1","selling_rate":"48147","buying_rate":"48311","delivery":"25-06-2020","retail_rate":"-"},{"com_id":"38","com_name":"GRKT999KG1","selling_rate":"48147","buying_rate":"48311","delivery":"25-06-2020","retail_rate":"-"}],"kb":[{"com_id":"19","com_name":"ONLINE GOLD BAR","selling_rate":"4967.00","buying_rate":"-","delivery":"26-06-2020","retail_rate":"-"},{"com_id":"26","com_name":"SABARISH JEWELLERY","selling_rate":"4970.00","buying_rate":"-","delivery":"26-06-2020","retail_rate":"-"}],"novnath":[{"com_id":"57","com_name":"Gold  ","selling_rate":"4969","buying_rate":"-","delivery":"25-06-2020","retail_rate":"-"}]}

  2. #2
    Administrator
    Join Date
    Feb 2012
    Location
    Milano
    Posts
    716
    Hi

    From Lightstreamer point of view, the most natural mapping for a dynamic list of stocks is definitely an item in COMMAND mode.
    Obviously this requires that in your adapter you have to unpack the json structure and detect all the changes that have occurred: new stock added, deletion of an existing stock, update of the values for an existing stock, and push these updates to the Lightstreamer server as ADD, DELETE, and UPDATE commands.
    In this case the key field should be associated with com_id.

    Then in the client you will no longer need the json structure at all.
    Unless, maybe because you already have some client code based on the json, you actually need it; however in this case it should be easy to obtain back the json structure from the updates received through the Item in COMMAND mode.

    Regards,
    Giuseppe

  3. #3
    Power Member
    Join Date
    Sep 2013
    Location
    Coimbatore
    Posts
    121
    Hello,
    Could you please clarify in data structure in the second point how to I have to change the structure for clients rates.

  4. #4
    Administrator
    Join Date
    Feb 2012
    Location
    Milano
    Posts
    716
    In vb there is some system utilities (this for example) that help to serialize and deserialize from json to a common collection object, such a Dictionary, or a List, ...
    In this case you could keep up to date a dictionary with the updates received by the server and serialize to a json for display if that helps.

    Regards,
    Giuseppe

  5. #5
    Power Member
    Join Date
    Sep 2013
    Location
    Coimbatore
    Posts
    121
    Hello,
    Now I have created structure like this,
    [{"com_id":"33","com_name":"GOLD BAR","selling_rate":"4952","buying_rate":"-","delivery":"30-06-2020","retail_rate":"-","client":"lmxtrade","client_com_id":"lmxtrade_33"},{"com_id":"36","com_name":"GOLD FT","selling_rate":"4952","buying_rate":"4751","de livery":"30-06-2020","retail_rate":"-","client":"lmxtrade","client_com_id":"lmxtrade_36 "},{"com_id":"37","com_name":"GOLD RTGS","selling_rate":"4852","buying_rate":"-","delivery":"30-06-2020","retail_rate":"-","client":"lmxtrade","client_com_id":"lmxtrade_37"},{"com_id":"38","com_name":"SILVER","selling_rate ":"48955","buying_rate":"48428","delivery":"30-06-2020","retail_rate":"-","client":"lmxtrade","client_com_id":"lmxtrade_38"},{"com_id":"33","com_name":"GOLD CBE RTGS ","selling_rate":"4943","buying_rate":"4831","deli very":"30-06-2020","retail_rate":"-","client":"kkvtrade","client_com_id":"kkvtrade_33 "},{"com_id":"36","com_name":"GOLD FT","selling_rate":"4943","buying_rate":"4841","de livery":"30-06-2020","retail_rate":"-","client":"kkvtrade","client_com_id":"kkvtrade_36"},{"com_id":"37","com_name":"GOLD RTGS","selling_rate":"4843","buying_rate":"4941"," delivery":"30-06-2020","retail_rate":"-","client":"kkvtrade","client_com_id":"kkvtrade_37 "},{"com_id":"38","com_name":"SILVER","selling_rat e":"48455","buying_rate":"48428","delivery":"30-06-2020","retail_rate":"-","client":"kkvtrade","client_com_id":"kkvtrade_38 "}]
    wlclientrates : "[{\"com_id\":\"33\",\"com_name\":\"GOLD BAR\",\"selling_rate\":\"4952\",\"buying_rate\":\"-\",\"delivery\":\"30-06-2020\",\"retail_rate\":\"-\",\"client\":\"lmxtrade\",\"client_com_id\":\"lmx trade_33\"},{\"com_id\":\"36\",\"com_name\":\"GOLD FT\",\"selling_rate\":\"4952\",\"buying_rate\":\"4 751\",\"delivery\":\"30-06-2020\",\"retail_rate\":\"-\",\"client\":\"lmxtrade\",\"client_com_id\":\"lmx trade_36\"},{\"com_id\":\"37\",\"com_name\":\"GOLD RTGS\",\"selling_rate\":\"4852\",\"buying_rate\":\ "-\",\"delivery\":\"30-06-2020\",\"retail_rate\":\"-\",\"client\":\"lmxtrade\",\"client_com_id\":\"lmx trade_37\"},{\"com_id\":\"38\",\"com_name\":\"SILV ER\",\"selling_rate\":\"48955\",\"buying_rate\":\" 48428\",\"delivery\":\"30-06-2020\",\"retail_rate\":\"-\",\"client\":\"lmxtrade\",\"client_com_id\":\"lmx trade_38\"},{\"com_id\":\"33\",\"com_name\":\"GOLD CBE RTGS \",\"selling_rate\":\"4943\",\"buying_rate\":\"483 1\",\"delivery\":\"30-06-2020\",\"retail_rate\":\"-\",\"client\":\"kkvtrade\",\"client_com_id\":\"kkv trade_33\"},{\"com_id\":\"36\",\"com_name\":\"GOLD FT\",\"selling_rate\":\"4943\",\"buying_rate\":\"4 841\",\"delivery\":\"30-06-2020\",\"retail_rate\":\"-\",\"client\":\"kkvtrade\",\"client_com_id\":\"kkv trade_36\"},{\"com_id\":\"37\",\"com_name\":\"GOLD RTGS\",\"selling_rate\":\"4843\",\"buying_rate\":\ "4941\",\"delivery\":\"30-06-2020\",\"retail_rate\":\"-\",\"client\":\"kkvtrade\",\"client_com_id\":\"kkv trade_37\"},{\"com_id\":\"38\",\"com_name\":\"SILV ER\",\"selling_rate\":\"48455\",\"buying_rate\":\" 48428\",\"delivery\":\"30-06-2020\",\"retail_rate\":\"-\",\"client\":\"kkvtrade\",\"client_com_id\":\"kkv trade_38\"}]"
    here client_com_id will be unique for every clients. Can you please help me on the logic to connect the client and serve only respected clients rates. Here in this list will be having all the clients rates. Is this possible to connect the client who is passing the client name with request and send represent client data from server.

  6. #6
    Administrator
    Join Date
    Feb 2012
    Location
    Milano
    Posts
    716
    Hi,

    The scenario you described requires a personalized Item. I mean that each user subscribes to a specific Item reserved to the specific user.
    The Item name could be the client_com_id itself, if the client knows it this makes things easy; otherwise you have to make a customization in the Metadata Adapter (getItem method).

    Then in the adapter when you parse the json, for each element you first check the client_com_id, and then you will update the personalized Item with Command mode 'ADD', 'UPDATE', or 'DELETE' depending on the com_id.

    Please let us know if you need any further clarifications.

    Regards,
    Giuseppe

  7. #7
    Power Member
    Join Date
    Sep 2013
    Location
    Coimbatore
    Posts
    121
    Hello,
    Need to subscribe set of items, in this above json list "client":"lmxtrade", this lmxtrade will be send from client this have to connect with LS server and need to server lmxtrade list, this list will have n number of row.

  8. #8
    Administrator
    Join Date
    Feb 2012
    Location
    Milano
    Posts
    716
    You have both options available.
    Or have different Items all customized according to the user, and the client must explicitly subscribe to all of these.
    Or manage only one Item, obviously also customized for the user, with the list managed dynamically on the server side. In this case you need to use the COMMAND subscribe mode.
    For further details about COMMAND mode you can refer to Portfolio example: https://github.com/Lightstreamer/Lig...---html-client

    Regards,
    Giuseppe

  9. #9
    Power Member
    Join Date
    Sep 2013
    Location
    Coimbatore
    Posts
    121
    I have previously used COMMAND mode and I have created separate remote adapter for individual clients. For example in this above data structure there having 2 clients lmxtrade and kkvtrade. For each clients I have created individual adapter and run the adapter in separate port numbers.

    Now I have planned to run in single adapter to subscribe multiple client account. For example I have 2 domains to show their commodity trading data. But this both LS client request to get data from single LS server. In this case how I need to bind the data to serve respected clients.
    And I need to know how the client name send to LS server from LS client. Whether via request header or any other method is there.
    And also I need to know whether I have to change the data structure in LS server like
    {"vb":[{"com_id":"41","com_name":"GOLD - SALEM","selling_rate":"4977.00","buying_rate":"-","delivery":"25-06-2020","retail_rate":"-"},{"com_id":"38","com_name":"SILVER - SALEM","selling_rate":"49880.00","buying_rate":"-","delivery":"25-06-2020","retail_rate":"-"}],"akumar":[{"com_id":"33","com_name":"GSUT999KG1","selling_ra te":"48147","buying_rate":"48311","delivery":"25-06-2020","retail_rate":"-"}],"kb":[{"com_id":"19","com_name":"ONLINE GOLD BAR","selling_rate":"4967.00","buying_rate":"-","delivery":"26-06-2020","retail_rate":"-"}]}
    I feel this above data structure is difficult to do ADD, DELETE and UPDATE in COMMAND mode. So only I have changed the structure as like below structure
    [{"com_id":"33","com_name":"GOLD BAR","selling_rate":"4952","buying_rate":"-","delivery":"30-06-2020","retail_rate":"-","client":"lmxtrade","client_com_id":"lmxtrade_33 "},{"com_id":"36","com_name":"GOLD FT","selling_rate":"4952","buying_rate":"4751"," de livery":"30-06-2020","retail_rate":"-","client":"lmxtrade","client_com_id":"lmxtrad e_36 "},{\"com_id\":\"36\",\"com_name\":\"GOLD FT\",\"selling_rate\":\"4943\",\"buying_rate\":\" 4 841\",\"delivery\":\"30-06-2020\",\"retail_rate\":\"-\",\"client\":\"kkvtrade\",\"client_com_id\":\" kkv trade_36\"},{\"com_id\":\"38\",\"com_name\":\"SILV ER\",\"selling_rate\":\"48455\",\"buying_rate\":\ " 48428\",\"delivery\":\"30-06-2020\",\"retail_rate\":\"-\",\"client\":\"kkvtrade\",\"client_com_id\":\" kkv trade_38\"}]
    In this above structure client_com_id will be unique. I have to subscribe by using "client" column.

  10. #10
    Administrator
    Join Date
    Feb 2012
    Location
    Milano
    Posts
    716
    Hi,

    Perhaps the most appropriate way to pass client information to the adapter is through extra http headers.
    Please check out the documentation of this method https://lightstreamer.com/api/ls-web...tpExtraHeaders
    But in the case if you are not already using it for real authentication, you can use the user info: https://lightstreamer.com/api/ls-web...s.html#setUser

    Then you need to keep a structure in your metadata that associates each client session with the client name.
    At this point in the getItems method you can customize the Item subscribed by the client name pertaining to the involved client session.

    I understand the change to the data structure, I think it makes sense.

    Regards,
    Giuseppe

 

 

Similar Threads

  1. how many server adapter are created?
    By josephpanchal in forum General
    Replies: 1
    Last Post: October 21st, 2019, 10:35 AM
  2. Creating adapter for dynamic stock list
    By rvkvino in forum General
    Replies: 1
    Last Post: February 14th, 2017, 10:22 AM
  3. how many server adapter are created?
    By brunovaghi in forum General
    Replies: 1
    Last Post: September 30th, 2016, 09:58 AM
  4. Snapshot in Remote Data Adapter
    By Dejan Milosevic in forum Adapter SDKs
    Replies: 5
    Last Post: July 31st, 2014, 04:06 PM
  5. Add dynamic data in Server and update it to Client
    By giangum in forum Client SDKs
    Replies: 1
    Last Post: September 1st, 2009, 10:20 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT +1. The time now is 02:17 PM.