Results 1 to 10 of 10
  1. #1
    Senior Member
    Join Date
    Sep 2008
    Location
    rmd
    Posts
    30

    dynamically subscribe items

    As far as I've understood, the list of items to be subscribed should be sent by the client(in may case a web client)

    Is it possible to do the following scenario using lightstreamer?

    Depending on the username password sent by web client, lightstreamer connects to the database and gets the list of items relevant to that user. then it sends them back to the client or subscribe those items automatically... and pushes data accordingly. (i.e. web client will send us only the username and we have to subscribe the relevant items for that user)


    regards
    rd

  2. #2
    Administrator
    Join Date
    Jul 2006
    Location
    Milan, Italy
    Posts
    517
    Yes, there are several ways to achieve that with Lightstreamer. Here are a couple of options:

    A) The Client specifies a generic group name in its subscription. Your Metadata Adapter, based on the user identity (previously assessed through username and password), will expand such group name into a list of specific items (this is done through the getItems method). With a Web Client, this works well with NonVisualTables; with VisualTables it is better If the client knows in advance how many items it wants to display in that page, in order to prepare the cells.

    B) Use a MultiDynaMetapushTable, released with Web Client v.4.3, to have th Server dynamically push a list of items to the Client (with even the capability of removing items at any times). Take a look at the brand new Portfolio Demo released with Lightstreamer Server v.3.5.

  3. #3
    Senior Member
    Join Date
    Sep 2008
    Location
    rmd
    Posts
    30

    using nonvisual tables

    Thanks
    happy to here that i'm in the right track. i was doing some POCs with getItems.

    In my case i'm using non visual tables.

    in getItems(user,id) in MetaAdapter i check the user and depending on the user i set different values for the id string (irrespective of whatever is coming as id) I dd no change to the subscribe method in dataadapter.

    still i ddnt get a good response.
    onItemupdate (in javascript) the itemName comes as undefined.... any hints?

  4. #4
    Senior Member
    Join Date
    Sep 2008
    Location
    rmd
    Posts
    30

    SubscriptionMode

    can it be a issue in subscription mode? I'm using MERGE. all other three (RAW,DISTINCT and COMMAND says that they are not supported for item1

  5. #5
    Senior Member
    Join Date
    Sep 2008
    Location
    rmd
    Posts
    30
    If i initially send(from javascript) all the names of items, it works without any prob(for the timebeing forget the username password word)

    but if i try to add any item name that is not in the initial list, it is shown as undefined in the onitemupdate event(in js).. (i can dynamically remove items from the list, depending on the user)

    is this relates to the listener.update in dataadapter?

    public String[] getItems(String user, String id) throws ItemsException {
    String group = "item1 "+ "item2 "+"item3 "+"item4 "+"item5 "+"item6";
    return tokenize(group);
    }

    in my javascript
    //var ngroup = ["item1","item2","item3","item4","item5","item6","i tem7"];
    //this works fine and will subscribe only item1 to item6 and updates them correctly
    var ngroup = ["items"];
    var nvTable = new NonVisualTable(ngroup,nschema,"MERGE");
    onItemUpdate
    nvTable.onItemUpdate = function(itemIndex,update,itemName) {
    alert(itemName);// this alerts "undefined" if i use ngroup = ["items"]
    }

  6. #6
    Senior Member
    Join Date
    Sep 2008
    Location
    rmd
    Posts
    30

    onitemupdate

    it gives the correct itemIndex, but not the correct itemName . it seems that it generates the itemName from the group defined in the js, not from the metaadapter.

  7. #7
    Administrator
    Join Date
    Jul 2006
    Location
    Milan
    Posts
    975
    When you use a generic "group name" to be expanded into a list of item names by the Metadata Adapter, as in
    var ngroup = ["items"];
    the generated item names are not communicated to the client library (see the onItemUpdate doc).
    If you really need those names on your front-end, you can setup a new field to ask for them.
    The client can still discriminate the items by their numeric "itemIndex".

    About the subscription mode, note that they must obey some restrictions (see paragraph 3.1 in General Concepts.pdf).
    However, you are free to configure the proper modes for your items, through the "modeMayBeAllowed" method of your Metadata Adapter.
    You are probably still inheriting the configuration of the StockListDemo, which is made through the <item_family_...> elements in "adapters.xml", managed by the LiteralBasedProvider.

  8. #8
    Senior Member
    Join Date
    Sep 2008
    Location
    rmd
    Posts
    30
    yes it works

  9. #9
    Senior Member
    Join Date
    Sep 2008
    Location
    rmd
    Posts
    30

    Question get the list of subscribed items

    any way, in this method is there any way to get the list of all the subscribed items initially.
    or at least the number of items that is subscribed to that user?

    To create the table correctly, i need the number of subscribed items in the web client. is it possible to catch it in the onStart() method in js or in some other method. Also can you please elaborate the use of setSnapshotRequried(true) onEngineCreation. I think i may use it. can you please elaborate?

  10. #10
    Administrator
    Join Date
    Jul 2006
    Location
    Milan
    Posts
    975
    This metainformation is not supplied, though your suggestion about onStart makes sense.
    At the moment, you would need to setup a separate item to get this information.
    The group names were introduced as shortcuts for known sets of items, like stock lists.
    Note that, for unknown sets, the COMMAND mode is also available, though it covers the more generic case of dynamic sets and requires specific handling by the Data Adapter.

    By issuing setSnapshotRequired(true), you ask for a preliminary update about the current state of the item (for each item in the table). The Server tries to send this update immediately.
    The snapshot is covered in the "DOCS-SDKs/General Concepts.pdf" document, paragraph 3.4.1.

    onEngineCreation allows you to perform Engine initialization (The Engine page connects to Lightstreamer Server on behalf of one or more Push-Pages). The Master Push-page, after creating the Engine through "createEngine", receives a call to the onEngineCreation callback, through which it can (and should) configure the Engine so that it can access the Server.
    Details can be found in the online documentation, but the normal usage is best described by the provided sample pages.

 

 

Similar Threads

  1. Automatic subscribe to different items
    By abhijeetgk in forum Adapter APIs
    Replies: 1
    Last Post: September 28th, 2011, 11:53 AM
  2. Non-blocking IDataProvider.Subscribe
    By bartol82 in forum Adapter APIs
    Replies: 1
    Last Post: August 30th, 2011, 11:15 AM
  3. Adding/Removing items dynamically
    By Otake in forum Client APIs
    Replies: 5
    Last Post: December 17th, 2009, 03:15 PM
  4. subscribe to items not using threads
    By nagakumaran in forum Adapter APIs
    Replies: 6
    Last Post: October 16th, 2007, 03:11 PM
  5. Dynamically size a table
    By Mone in forum Client APIs
    Replies: 2
    Last Post: May 7th, 2007, 03:59 PM

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 03:36 AM.