Results 1 to 10 of 21

Hybrid View

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

    The 'CONNECTED' prefix actually guarantees that a physical connection with the server has already been established.
    Only in the 'CONNECTED: STREAM-SENSING' case, which should be a quick transient, the client library is still evaluating the most suitable transport (Websocket, HTTP-Streaming, or polling) to use for the client session depending on the network conditions of the client.
    Anyway please double check the documentation for all the casistics: https://sdk.lightstreamer.com/ls-web...onStatusChange

    Finally, please let me stress out again that for subscribe requests you should not care about the status of the LightstreamerClient.

    Regards,
    Giuseppe

  2. #2
    Thanks. I'll look into that further. I have all this working nicely and in the final optimization steps of the code. So:

    1. Given we get a subscription object via
    let subscription = new Subscription(subscriptionMode, items, fields)
    is there a way to do a reverse look up to get a subscription based on a given item? I.e.:
    let subscription = new GetSubscription(item)
    (see NOTE 1 below for my solution)
    2. Similarly, if I RE-subscribe to the same EXACT 'items' array above do I get the same subscription reference or a new one?

    The reason for this, as always, is decoupling. In this case, I've already decoupled various modules of the app to use the same Client instance (vertical decoupling) and if no CLIENT exists to create their own.
    Similarly, I'm also decoupling the UI components inside the module to not be concerned with their stream or subscription source (in this case Lightstreamer and Subscription) which is 'horizontal decoupling' within the module. The most the UI components know about is a string (we internally call a 'topic') where a separate decoupled service can construct an 'item' from that 'topic' to pass to a
    let subscription = new Subscription(subscriptionMode, createItem('topic'), fields).
    Similarly when the UI component is destroyed it will unsubscribe('topic') as its last act--it knows nothing of Clients or Subscriptions or Lightstreamer and only knows the 'topic' string. I ideally do not want to manage my own Map<topic, subscription> internally OR pass the subscription handle or any other LS artifacts to the UI components.

    NOTE 1: Given the documentation, reverse look-up can be done by the following psuedocode;
    let subscriptions = _lightstreamerClient.getSubscriptions()
    for (subscription in subscriptions) {
    let items = subscription.getItems()
    for (item in items) {
    if item.includes('topic') exit both loops with found subscription object...
    }
    }
    NOTE 2: For your reference, I'm managing that decoupled service using an NgRx state machine.

    Thanks.
    Last edited by Megabyzus; April 25th, 2022 at 04:39 PM.

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

    Thank you for the feedback about your integration process.

    About your questions:

    1. I can confirm that the combination of getSubscriptions and then getItems, as per your pseudocode of NOTE 1, is a good solution since there is no direct method that returns the set of active subscriptions for a given list of Items.

    2. No, if you call subscribe with the same parameters (mode, items list and fields list) of a previous one the LightstreamerClient will create a brand new subscription in addition to the old one.
    Basically you will receive the same data twice.

    Regards,
    Giuseppe

  4. #4
    Quote Originally Posted by giuseppe.corti View Post
    Hi Megabyzus,
    1. I can confirm that the combination of getSubscriptions and then getItems, as per your pseudocode of NOTE 1, is a good solution since there is no direct method that returns the set of active subscriptions for a given list of Items.
    Thanks. To be clear, since there is no 1 - 1 correspondence between items and subscriptions (i.e. we can have multiple subscription references to the same items and vice versa) then my pseudocode needs to be modified to return an array of subscriptions for identical items. Then those array elements need to be individually unsubscribed. In other words, questions 1 & 2 in my mentioned post were related.

    Thanks!
    Last edited by Megabyzus; April 29th, 2022 at 06:47 PM.

 

 

Similar Threads

  1. Replies: 27
    Last Post: October 21st, 2020, 10:30 AM
  2. Replies: 6
    Last Post: July 11th, 2016, 09:27 AM
  3. Replies: 3
    Last Post: August 16th, 2011, 10:39 AM
  4. J2EE app to push message via LS w/o JMS
    By atamel in forum General
    Replies: 3
    Last Post: August 9th, 2010, 02:09 PM
  5. Replies: 1
    Last Post: November 18th, 2009, 09:44 PM

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 09:53 PM.