Results 1 to 7 of 7
  1. #1

    Trying to create a simple ticker


    Past few days been trying to learn how to use lightstreamer. I managed to follow the helloworld node.js example and create a simple node.js adapter and use a StaticGrid to show Hello World.

    Next I had my node.js adapter connect to another server that just throws sentences out through the socket.
    I would still use the StaticGrid to display the messages I get relayed from my server fine.

    Now instead of just merging the data on the static grid and showing one line, I want to create a ticker displaying the messages I get from the server.

    Am I suppose to use a DynaGrid this time?
    Will my subscription mode now be DISTINCT?

    Hope someone can point me to the right direction! Thanks!

  2. #2
    Join Date
    Feb 2012
    Hi Gino,

    The choice of the subscription mode should be driven by the characteristics of the data source rather than by the way in which the data will be displayed.

    For example, if in your ticker display you have stock quote updates the MERGE mode is the best choice. Each stock is represented by an Item and the data on the last price, the percentage of variation etc. are handled to have only the more fresh value.
    But, if you need to display some kind of news then the DISTINCT mode has to be preferred, unless the collection of news to be displayed is changing continuosly, with news to add or remove dinamically. In that case you can use the COMMAND mode. Please refer to this demo for a similar example.

    Is sure that the DynaGrid allows you to display more rows also dynamically with all three types of subscription mode but does not allow you to display the sentences in a ticker style format.
    You can easily use any JavaScript Ticker component that accepts client-side injection of values. The integration with Lightstreamer will be straightforward.


  3. #3
    Hi Giuseppe,

    Thanks for taking the time to clarify those concepts and providing the RSS example will start studying it now. I've been stuck trying to make a DISTINCT subscription work with my DynaGrid. What I have been doing was just working on the HelloWorld tutorials provided here in the site. I've successfully modified my node.js adapter to create a connection to another remote server and send updates to all subscribers whenever the remote server sends a message. The client is still the same as the HelloWorld example that displays the messages using the MERGE mode.

    Now what I wanted to do was instead of having the messages display on the div, I wanted each message to displayed as a list. From my understanding if I use MERGE this will simply replace the data-fields on my grid, which in this case was a StaticGrid.
    To be able to have a list of all the messages that were past, I need to use the DISTINCT mode and a DynaGrid so that a row is dynamically added to my container when a message comes. Problem is when I start my client, no error happens but no message is displayed. If I change my subscription to MERGE the data will display but I don't get to list the messages in a list.

    Here's my client code:

        <div id="ticker">      
          <div id="ticks" data-source="lightstreamer">        
            <div data-source="lightstreamer" data-field="message"></div>
            <div data-source="lightstreamer" data-field="timestap"></div>
          require(["LightstreamerClient","Subscription","DynaGrid"],function(LightstreamerClient,Subscription,DynaGrid) {
            var client = new LightstreamerClient(null,"NODE_DATAFEED");
            var ticker = new DynaGrid("ticks",true);
            var subscription = new Subscription("DISTINCT","messageData",ticker.extractFieldList());
    Again if I change the mode to MERGE the div will be updated and it will work just like the HelloWorld example. Now I want to list all the messages I receive. I don't see any errors but it seems like in DISTINCT mode I'm not receiving any data. Any idea why?

  4. #4
    Join Date
    Feb 2012
    Hi Gino,

    The same item can be subscribed in more modes by the same Client or by different Clients. But there are some incompatibilities for some combinations including precisely MERGE and DISTINCT.
    So, if your Lightstreamer server has the "messageData" Item already subscribed in MERGE mode by another client, the subsequent DISTINCT subscription will not receive any response.

    Please note that through the Metadata Adapter, with the function modeMayBeAllowed, you can exclude the possibility of subscribing an Item in certain modes.

  5. #5
    Hi Guiseppe,

    That was it! I had a client already subscribed to the same item in MERGE mode and thus was not receiving DISTINCT subscriptions.

    Regarding Dynagrids there's a method called setMaxDynaRows and in the documentation it says:

    Note that if this instance is used to listen to events from Subscription instance(s), and the first Subscription it listens to is a DISTINCT Subscription, then the behavior is different: when the limit posed by this setting is reached, adding a new row will always cause the removal of the oldest row from the model, with a consequent repositioning of the remaining rows.

    If I set my DynaGrid with a max row of 10 and I'm using a DISTINCT subscription does that mean I only maintain one page and just 10 rows at all times for this DynaGrid?

  6. #6
    Join Date
    Feb 2012
    Hi Gino,

    Yes, I confirm you that the behavior of DynaGrid with DISTINCT subscription is like you expect.

  7. #7
    Thanks Giuseppe for all the help!



Similar Threads

  1. How to create 2 engines in one page?
    By dimitarn in forum Client APIs
    Replies: 5
    Last Post: December 10th, 2009, 10:52 AM
  2. create .jar with .class
    By khalil78 in forum Adapter APIs
    Replies: 2
    Last Post: April 4th, 2008, 07:38 PM
  3. How to create Data Adapter?
    By Hanumant in forum Adapter APIs
    Replies: 3
    Last Post: January 29th, 2008, 03:42 PM
  4. Unable to create New DotNET Adapter
    By shobha in forum Adapter APIs
    Replies: 4
    Last Post: August 13th, 2007, 01:32 PM
  5. Trying to run LS through Https / SSL
    By wmolde in forum Client APIs
    Replies: 2
    Last Post: April 18th, 2007, 03:40 PM


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 12:08 PM.