简体   繁体   中英

Concept of snapshot and isActive() in LightStreamer

Reading documents of LightStreamer, some questions has remained which i cannot find them by reading docs.

  1. What is the concept of snapshot?
  2. What is difference between isActive() and isSubscribed() methods? If anyone is familiar with these in websocket programming, please guide me.

In Lightstreamer terms, you subscribe to "items", each of which models an entity characterized by a state and a flow of updates of that state. When you subscribe to an item, you may want to know the current state immediately; and then all subsequent updates, as soon as they occur. To simplify the interface, the state is sent to the client in the same format of the updates; so it is made by zero or more special updates. These special updates that carry the current state of the item are referred to as the snapshot.

The above is in abstract terms. The state of an entity can be made in many possible ways. For this reason Lightstreamer introduces several types of items (ie MERGE, DISTINCT and COMMAND), which cover basic types of state. They are described in detail by paragraph 3.2 of the General Concepts document.

2)

This distinction is introduced in client libraries, because these libraries represent each subscription with a Subscription object. This object specifies the characteristics of a subscription request (of one or multiple items), but this request, in order to be fulfilled, needs two steps: 1 the application submits the request to the client library; 2 the client library submits the request to Lightstreamer Server.

Hence, after 1, the object's isActive() returns true, whereas, after 2, the object's isSubscribed() also returns true. Note that the subscription request may have a complex lifecycle. For instance, if the connection to the Server gets lost, the client library reconnects and reissues the subscription; in the meantime, isActive() is true and isSubscribed() is false. Moreover, the application can later unsubscribe, but subsequently reuse the same Subscription object to request the same subscription again; in the meantime, isActive() is false (and isSubscribed() is obviously false).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM