Lightstreamer macOS Client
2.1.2
Native macOS Client library for Lightstreamer
|
Façade class for the management of the communication to Lightstreamer Server. More...
#import <LSLightstreamerClient.h>
Instance Methods | |
(nonnull instancetype) | - initWithServerAddress:adapterSet: |
Creates an object to be configured to connect to a Lightstreamer server and to handle all the communications with it. More... | |
(void) | - addDelegate: |
Adds a delegate that will receive events from the LSLightstreamerClient instance. More... | |
(void) | - connect |
Operation method that requests to open a Session against the configured Lightstreamer Server. More... | |
(void) | - disconnect |
Operation method that requests to close the Session opened against the configured Lightstreamer Server (if any). More... | |
(void) | - removeDelegate: |
Removes a delegate from the LSLightstreamerClient instance so that it will not receive events anymore. More... | |
(void) | - sendMessage: |
A simplified version of the #sendMessage:withSequence:timeout:delegate:enqueWhileDisconnected:. More... | |
(void) | - sendMessage:withSequence:timeout:delegate:enqueueWhileDisconnected: |
Operation method that sends a message to the Server. More... | |
(void) | - subscribe: |
Operation method that adds a LSSubscription to the list of "active" subscriptions. More... | |
(void) | - unsubscribe: |
Operation method that removes a LSSubscription that is currently in the "active" state. More... | |
Class Methods | |
(void) | + setLoggerProvider: |
Static method that permits to configure the logging system used by the library. More... | |
Properties | |
NSString * | LIB_NAME |
A constant string representing the name of the library. More... | |
NSString * | LIB_VERSION |
A constant string representing the version of the library. More... | |
BOOL | limitExceptionsUse |
Reduces the use of exceptions for error reporting. More... | |
LSConnectionOptions * | connectionOptions |
Bean object that contains options and policies for the connection to the server. More... | |
LSConnectionDetails * | connectionDetails |
Bean object that contains the details needed to open a connection to a Lightstreamer Server. More... | |
NSArray * | delegates |
List containing the LSClientDelegate instances that were added to this client. More... | |
NSString * | status |
Current client status and transport (when applicable). More... | |
NSArray * | subscriptions |
List containing all the LSSubscription instances that are currently "active" on this LightstreamerClient. More... | |
Façade class for the management of the communication to Lightstreamer Server.
Used to provide configuration settings, event handlers, operations for the control of the connection lifecycle, subscription handling and to send messages.
- (void) addDelegate: | (nonnull id< LSClientDelegate >) | delegate |
Adds a delegate that will receive events from the LSLightstreamerClient instance.
The same delegate can be added to several different LSLightstreamerClient instances. A delegate can be added at any time. A call to add a delegate already present will be ignored.
delegate | An object that will receive the events as documented in the LSClientDelegate interface. Note: delegates are stored with weak references: make sure you keep a strong reference to your delegates or they may be released prematurely. |
- (void) connect |
Operation method that requests to open a Session against the configured Lightstreamer Server.
When connect is called, unless a single transport was forced through LSConnectionOptions::forcedTransport, the so called "Stream-Sense" mechanism is started: if the client does not receive any answer for some seconds from the streaming connection, then it will automatically open a polling connection.
A polling connection may also be opened if the environment is not suitable for a streaming connection.
Note that as "polling connection" we mean a loop of polling requests, each of which requires opening a synchronous (i.e. not streaming) connection to Lightstreamer Server. Note that the request to connect is accomplished by the client in a separate thread; this means that an invocation of status right after connect might not reflect the change yet.
When the request to connect is finally being executed, if the current status of the client is CONNECTING, CONNECTED:* or STALLED, then nothing will be done.
NSException | if no server address was configured. |
NSException | if a LSConnectionOptions::maxConcurrentSessionsPerServerExceededPolicy of "BLOCKING" was specified an the current number of sessions open to the configured server address is equal to or greater than LSConnectionOptions::maxConcurrentSessionsPerServer. |
- (void) disconnect |
Operation method that requests to close the Session opened against the configured Lightstreamer Server (if any).
When disconnect is called, the "Stream-Sense" mechanism is stopped.
Note that active LSSubscription instances, associated with this LightstreamerClient instance, are preserved to be re-subscribed to on future Sessions.
Note that the request to disconnect is accomplished by the client in a separate thread; this means that an invocation of status right after disconnect might not reflect the change yet.
When the request to disconnect is finally being executed, if the status of the client is "DISCONNECTED", then nothing will be done.
- (nonnull instancetype) initWithServerAddress: | (nullable NSString *) | serverAddress | |
adapterSet: | (nullable NSString *) | adapterSet | |
Creates an object to be configured to connect to a Lightstreamer server and to handle all the communications with it.
Each LSLightstreamerClient is the entry point to connect to a Lightstreamer server, subscribe to as many items as needed and to send messages.
serverAddress | the address of the Lightstreamer Server to which this LightstreamerClient will connect to. It is possible to specify it later by using nil here. See LSConnectionDetails::serverAddress for details. |
adapterSet | the name of the Adapter Set mounted on Lightstreamer Server to be used to handle all requests in the Session associated with this LightstreamerClient. It is possible not to specify it at all or to specify it later by using nil here. See LSConnectionDetails::adapterSet for details. |
NSException | if a not valid address is passed. See LSConnectionDetails::serverAddress for details. |
- (void) removeDelegate: | (nonnull id< LSClientDelegate >) | delegate |
Removes a delegate from the LSLightstreamerClient instance so that it will not receive events anymore.
A delegate can be removed at any time.
delegate | The delegate to be removed. |
- (void) sendMessage: | (nonnull NSString *) | message |
A simplified version of the #sendMessage:withSequence:timeout:delegate:enqueWhileDisconnected:.
The internal implementation will call sendMessage:message withSequence:nil timeout:0 delegate:nil enqueWhileDisconnected:NO
message | a text message, whose interpretation is entirely demanded to the Metadata Adapter associated to the current connection. |
- (void) sendMessage: | (nonnull NSString *) | message | |
withSequence: | (nullable NSString *) | sequence | |
timeout: | (NSTimeInterval) | delayTimeout | |
delegate: | (nullable id< LSClientMessageDelegate >) | delegate | |
enqueueWhileDisconnected: | (BOOL) | enqueueWhileDisconnected | |
Operation method that sends a message to the Server.
The message is interpreted and handled by the Metadata Adapter associated to the current Session. This operation supports in-order guaranteed message delivery with automatic batching. In other words, messages are guaranteed to arrive exactly once and respecting the original order, whatever is the underlying transport (HTTP or WebSockets). Furthermore, high frequency messages are automatically batched, if necessary, to reduce network round trips.
Upon subsequent calls to the method, the sequential management of the involved messages is guaranteed. The ordering is determined by the order in which the calls to sendMessage are issued. However, any message that, for any reason, doesn't reach the Server can be discarded by the Server if this causes the subsequent message to be kept waiting for longer than a configurable timeout. Note that, because of the asynchronous transport of the requests, if a zero or very low timeout is set for a message, it is not guaranteed that the previous message can be processed, even if no communication issues occur.
Sequence identifiers can also be associated with the messages. In this case, the sequential management is restricted to all subsets of messages with the same sequence identifier associated.
Notifications of the operation outcome can be received by supplying a suitable delegate. The supplied delegate is guaranteed to be eventually invoked; delegates associated with a sequence are guaranteed to be invoked sequentially.
The "UNORDERED_MESSAGES" sequence name has a special meaning. For such a sequence, immediate processing is guaranteed, while strict ordering and even sequentialization of the processing is not enforced. Likewise, strict ordering of the notifications is not enforced. However, messages that, for any reason, should fail to reach the Server whereas subsequent messages had succeeded, might still be discarded after a server-side timeout. Since a message is handled by the Metadata Adapter associated to the current connection, a message can be sent only if a connection is currently active. If the special enqueueWhileDisconnected flag is specified it is possible to call the method at any time and the client will take care of sending the message as soon as a connection is available, otherwise, if the current status is "DISCONNECTED*", the message will be abandoned and the LSClientMessageDelegate::messageDidAbort event will be fired.
Note that, in any case, as soon as the status switches again to "DISCONNECTED*", any message still pending is aborted, including messages that were queued with the enqueueWhileDisconnected flag set to true.
Also note that forwarding of the message to the server is made in a separate thread, hence, if a message is sent while the connection is active, it could be aborted because of a subsequent disconnection. In the same way a message sent while the connection is not active might be sent because of a subsequent connection.
message | a text message, whose interpretation is entirely demanded to the Metadata Adapter associated to the current connection. |
sequence | an alphanumeric identifier, used to identify a subset of messages to be managed in sequence; underscore characters are also allowed. If the "UNORDERED_MESSAGES" identifier is supplied, the message will be processed in the special way described above. The parameter is optional; if set to nil, "UNORDERED_MESSAGES" is used as the sequence name. |
delayTimeout | a timeout, expressed in seconds. If higher than the Server default timeout, the latter will be used instead. The parameter is optional; if 0 is supplied, the Server default timeout will be applied. This timeout is ignored for the special "UNORDERED_MESSAGES" sequence, for which a custom server-side timeout applies. |
delegate | an object suitable for receiving notifications about the processing outcome. The parameter is optional; if not supplied, no notification will be available. Note: delegates are stored with weak references: make sure you keep a strong reference to your delegates or they may be released prematurely. |
enqueueWhileDisconnected | if this flag is set to true, and the client is in a disconnected status when the provided message is handled, then the message is not aborted right away but is queued waiting for a new session. Note that the message can still be aborted later when a new session is established. |
+ (void) setLoggerProvider: | (nonnull id< LSLoggerProvider >) | provider |
Static method that permits to configure the logging system used by the library.
The logging system must respect the LSLoggerProvider interface. A custom class can be used to wrap any third-party logging system.
If no logging system is specified, all the generated log is discarded.
The following categories are available to be consumed:
provider | A LSLoggerProvider instance that will be used to generate log messages by the library classes. |
- (void) subscribe: | (nonnull LSSubscription *) | subscription |
Operation method that adds a LSSubscription to the list of "active" subscriptions.
The LSSubscription cannot already be in the "active" state.
Active subscriptions are subscribed to through the server as soon as possible (i.e. as soon as there is a session available). Active LSSubscription are automatically persisted across different sessions as long as a related unsubscribe call is not issued. LSSubscriptions can be given to the LSLightstreamerClient at any time. Once done the LSSubscription immediately enters the "active" state.
Once "active", a LSSubscription instance cannot be provided again to a LSLightstreamerClient unless it is first removed from the "active" state through a call to unsubscribe:.
Also note that forwarding of the subscription to the server is made in a separate thread.
A successful subscription to the server will be notified through a LSSubscriptionDelegate::subscriptionDidSubscribe event.
subscription | A LSSubscription object, carrying all the information needed to process its pushed values. |
- (void) unsubscribe: | (nonnull LSSubscription *) | subscription |
Operation method that removes a LSSubscription that is currently in the "active" state.
By bringing back a LSSubscription to the "inactive" state, the unsubscription from all its items is requested to Lightstreamer Server. LSSubscription can be unsubscribed from at any time. Once done the LSSubscription immediately exits the "active" state.
Note that forwarding of the unsubscription to the server is made in a separate thread.
The unsubscription will be notified through a LSSubscriptionDelegate::subscriptionDidUnsubscribe event.
subscription | An "active" LSSubscription object that was activated by this LSLightstreamerClient instance. |
|
readnonatomicassign |
Bean object that contains the details needed to open a connection to a Lightstreamer Server.
This instance is set up by the LightstreamerClient object at its own creation.
Properties of this bean can be overwritten by values received from a Lightstreamer Server.
|
readnonatomicassign |
Bean object that contains options and policies for the connection to the server.
This instance is set up by the LSLightstreamerClient object at its own creation.
Properties of this bean can be overwritten by values received from a Lightstreamer Server.
|
readnonatomicassign |
List containing the LSClientDelegate instances that were added to this client.
|
readnonatomicassign |
A constant string representing the name of the library.
|
readnonatomicassign |
A constant string representing the version of the library.
|
readwritenonatomicassign |
Reduces the use of exceptions for error reporting.
When set to YES, the following method calls will return nil, instead of throwing an exception, when called with invalid parameters:
Default: NO
This value may be changed at any time.
|
readnonatomicassign |
Current client status and transport (when applicable).
|
readnonatomicassign |
List containing all the LSSubscription instances that are currently "active" on this LightstreamerClient.
Internal second-level LSSubscription are not included.