Click or drag to resize
ISession Interface
A session for making requests and subscriptions to services.

Sessions manage access to services either by requests and responses or subscriptions. A Session can dispatch events and replies in either a synchronous or asynchronous mode. The mode of a Session is determined when it is constructed and cannot be changed subsequently.

A session is asynchronous if an EventHandler is supplied when it is constructed. SetEventHandler(EventHandler, EventEventType) may be used to adjust the way events are handled subsequently and NextEvent may not be called. All incoming events are delivered to the event handler(s) supplied on construction or subsequently added with using SetEventHandler(EventHandler, EventEventType).

A session is synchronous if an EventHandler is not supplied when it is constructed. NextEvent must be called to read incoming events and SetEventHandler(EventHandler, EventEventType) may not be called.

When using an asynchronous Session the application must be aware that because the callbacks are generated from another thread they may be processed before the call which generates them has returned. For example, the SESSION_STATUSEvent generated by StartAsync may be processed before StartAsync returns (even though StartAsync itself will not block).

This becomes more significant when session-generated CorrelationID objects are in use. For example, if a call to Subscribe(IListSubscription, Identity, String) which returns a session-generated CorrelationID has not completed before the first events which contain that CorrelationID arrive the application may not be able to interpret those events correctly. For this reason, it is preferable to use a user generated CorrelationID when using an asynchronous Session. This issue does not arise when using a synchronous Session as long as the calls to Subscribe(IListSubscription, Identity, String) etc are made on the same thread as the calls to NextEvent.

Namespace:  Bloomberglp.Blpapi
Assembly:  Bloomberglp.Blpapi (in Bloomberglp.Blpapi.dll) Version: 3.24.10.1
Syntax
public interface ISession : IAbstractSession, 
	IDisposable

The ISession type exposes the following members.

Methods
  NameDescription
Public methodCancel(CorrelationID)
Cancels an outstanding request or a subscription.
(Inherited from IAbstractSession.)
Public methodCancel(IListCorrelationID)
This is the same as calling Cancel(CorrelationID, String) with a null request label.
(Inherited from IAbstractSession.)
Public methodCancel(CorrelationID, String)
Cancels an outstanding request or a subscription.
(Inherited from IAbstractSession.)
Public methodCancel(IListCorrelationID, String)
Cancels outstanding requests or subscriptions.

Cancels a previous request or subscription for asynchronous topic updates associated with each CorrelationID in correlators. Upon return, no further message will be generated for those requests or subscriptions.

For asynchronous sessions, a handler may still be processing an existing message for the associated request or subscription after the call returns. While iterating over an event, if any message is encountered for a cancelled CorrelationID, it will be silently ignored, but if the message was iterated to just prior to the completion of the cancel request it will be delivered, it is up to the application developer to handle this condition.

If any of the specified CorrelationIds do not refer to an "active" request or Subscription then, that particular CorrelationID will be ignored.

Once this call returns, the specified CorrelationID can be reused for new requests to this session. Also note that application developers should generally be cautious not to reuse a CorrelationID until all existing references within their applications have been cleared. Depending on the use of the CorrelationID, this can possibly result in accessing application resources which are no longer available.

(Inherited from IAbstractSession.)
Public methodCreateIdentity
Creates a new Identity which is valid but has not been authorized.

Create a handle to represent a user of services. For using services with the specific user's credentials the identity should be authorized with the corresponding authorization service.

(Inherited from IAbstractSession.)
Public methodcreateSnapshotRequestTemplate(String, CorrelationID)
Public methodcreateSnapshotRequestTemplate(String, CorrelationID, Identity)
Create a snapshot service request template for getting subscription data.

When creating a snapshot requests a subscription is established, but messages are sent to the application only when requested. This reduces latency for receiving the latest data when compared to starting a new subscription each time.

Public methodGenerateAuthorizedIdentity
Generates an authorized Identity with the specified authOptions and cid.

One or more AUTHORIZATION_STATUS events, zero or more TOKEN_STATUS events and zero or more SERVICE_STATUS events are generated. If this is an asynchronous AbstractSession then an Event may be processed by the registered EventHandler before GenerateAuthorizedIdentity(AuthOptions, CorrelationID) has returned.

The behavior is undefined when authOptions is null.

(Inherited from IAbstractSession.)
Public methodGenerateToken
This is the same as calling GenerateToken(String, String, CorrelationID, IEventQueue) with all null arguments.
(Inherited from IAbstractSession.)
Public methodGenerateToken(CorrelationID)
This is the same as calling GenerateToken(String, String, CorrelationID, IEventQueue) with a null user ID and IP address and a null IEventQueue.
(Inherited from IAbstractSession.)
Public methodGenerateToken(CorrelationID, IEventQueue)
This is the same as calling GenerateToken(String, String, CorrelationID, IEventQueue) with a null user ID and IP address.
(Inherited from IAbstractSession.)
Public methodGenerateToken(String, String, CorrelationID, IEventQueue)
Generate a token to be used for authorization.

Valid authentication options must have been specified in the SessionOptions.

(Inherited from IAbstractSession.)
Public methodGetAuthorizedIdentity
Gets an authorized Identity. A CorrelationID that maps to an authorized Identity.

If cid is omitted and the session identity is authorized, the function will return the session identity.

An authorized identity must be mapped to cid. If cid is omitted the session identity must have been authorized.

(Inherited from IAbstractSession.)
Public methodGetService
Gets the Service object.
(Inherited from IAbstractSession.)
Public methodGetSubscriptions
Returns an enumerable collection of all subscriptions in this session.
Public methodGetSubscriptionStatus
Returns the subscription status for a given CorrelationID.
Public methodGetSubscriptionString
Returns the subscription string for a given CorrelationID.
Public methodNextEvent
This is the same as NextEvent(Int64) with 0 milliseconds.
(Inherited from IAbstractSession.)
Public methodNextEvent(Int64)
Returns the next event available for processing on this session.

If no event is available immediately wait for timeoutMillis milliseconds for an event to arrive. If no event is received before the timeout expires return a TIMEOUT event. If the timeout specified is 0 then wait for an infinite amount of time for an event to be received. Note that this function cannot be called on a session that is operating in "asynchronous" mode. That is a session that was constructed with an EventHandler.

An EventHandler must not have been provided at construction.
(Inherited from IAbstractSession.)
Public methodOpenService
Opens the service.
(Inherited from IAbstractSession.)
Public methodOpenServiceAsync(String)
Issues an asynchronous request to open a service.
(Inherited from IAbstractSession.)
Public methodOpenServiceAsync(String, CorrelationID)
Initiates an asynchronous request to open a service.

Once the request has completed, a SERVICE_STATUS event will be generated indicating the result of the request. The correlationId will be returned in generated message. It can also be used to cancel this request before it completes by calling Cancel(CorrelationID).

(Inherited from IAbstractSession.)
Public methodResubscribe(IListSubscription)
Public methodResubscribe(IListSubscription, SubscriptionPreprocessMode)
This is the same as calling Resubscribe(subscriptionList, requestLabel: null, mode) with null request label.
Public methodResubscribe(IListSubscription, Int32)
Public methodResubscribe(IListSubscription, String)
Modifies subscriptions to reflect the modified options specified for them.
Public methodResubscribe(IListSubscription, Int32, SubscriptionPreprocessMode)
Public methodResubscribe(IListSubscription, Int32, String)
Modifies subscriptions to reflect the modified options specified for them.
Public methodResubscribe(IListSubscription, String, SubscriptionPreprocessMode)
Modifies subscriptions to reflect the modified options specified for them.
Public methodResubscribe(IListSubscription, Int32, String, SubscriptionPreprocessMode)
Modifies subscriptions to reflect the modified options specified for them.
Public methodSendAuthorizationRequest(Request, Identity, CorrelationID)
This is the same as calling SendAuthorizationRequest(Request, Identity, IEventQueue, CorrelationID, String) with a null IEventQueue and null request label.
(Inherited from IAbstractSession.)
Public methodSendAuthorizationRequest(Request, Identity, CorrelationID, String) (Inherited from IAbstractSession.)
Public methodSendAuthorizationRequest(Request, Identity, IEventQueue, CorrelationID)
This is the same as calling SendAuthorizationRequest(Request, Identity, IEventQueue, CorrelationID, String) with a null request label.
(Inherited from IAbstractSession.)
Public methodSendAuthorizationRequest(Request, Identity, IEventQueue, CorrelationID, String)
Authorizes an identity.

This request can be used by applications to authorize users to receive data from services. If a user is successfully authorized all the entitlements for that user are cached locally. Once authorized the identity can be used to make subscriptions and requests as the user.

If an IEventQueue is specified then all response events for this Authorization Request are published to this event queue. The user can block on this event queue for responses and can use this as a mechanism to convert this asynchronous request into a synchronous request.

An Event will be published containing a message with the result of the authorization request. If the user was successfully authorized an "AuthorizationSuccess" message will be generated. If the user was not authorized an "AuthorizationFailure" message will be generated.

(Inherited from IAbstractSession.)
Public methodSendRequest(RequestTemplate)
This is the same as calling SendRequest(RequestTemplate, CorrelationID) with null CorrelationID.
Public methodSendRequest(Request, CorrelationID)
This is the same as calling SendRequest(Request, Identity, IEventQueue, CorrelationID, String) with null Identity, null IEventQueue and null request label.
Public methodSendRequest(RequestTemplate, CorrelationID)
Send a request based on a RequestTemplate.

A successful request will generate zero or more PARTIAL_RESPONSE events followed by exactly one RESPONSE event. Once the final RESPONSE event has been received the CorrelationID associated with this request may be re-used. If the request fails at any stage a REQUEST_STATUS will be generated after which the CorrelationID associated with the request may be re-used.

Public methodSendRequest(Request, CorrelationID, String)
Public methodSendRequest(Request, Identity, CorrelationID)
This is the same as calling SendRequest(Request, Identity, IEventQueue, CorrelationID, String) with null IEventQueue and null request label.
Public methodSendRequest(Request, IEventQueue, CorrelationID)
This is the same as calling SendRequest(Request, Identity, IEventQueue, CorrelationID, String) with null Identity and null request label.
Public methodSendRequest(Request, Identity, CorrelationID, String)
Public methodSendRequest(Request, Identity, IEventQueue, CorrelationID)
This is the same as calling SendRequest(Request, Identity, IEventQueue, CorrelationID, String) with null request label.
Public methodSendRequest(Request, IEventQueue, CorrelationID, String)
Public methodSendRequest(Request, Identity, IEventQueue, CorrelationID, String)
Sends a request to a service.

A successful request will generate zero or more PARTIAL_RESPONSE events followed by exactly one RESPONSE event. Once the final RESPONSE event has been received the CorrelationID associated with this request may be re-used. If the request fails at any stage a REQUEST_STATUS event will be generated after which the CorrelationID associated with the request may be re-used.

The number of enqueued requests must not exceed the amount specified in MaxPendingRequests when this session was created.

Public methodSetEventHandler
Set event specific event handlers.
Public methodStart
Issues a blocking call to start the session.

A SESSION_STATUS event may be published containing a message with the result of the request. If the session was started successfully a "SessionStarted" message will be generated. If the start failed a "SessionStartupFailure" message may be generated.

Note: If this is an asynchronous session then the SESSION_STATUS event may be processed by the registered EventHandler before this method has returned. If this session is using an external EventDispatcher it should be already started.

A session must only be started once.

(Inherited from IAbstractSession.)
Public methodStartAsync
Initiates a non blocking call to start the session.

On completion of this request a SESSION_STATUS event is published containing a message with the result of the request. If the session was started successfully a "SessionStarted" message will be generated. If the start failed a "SessionStartupFailure" message will be generated.

Note: If this is an asynchronous session then the SESSION_STATUS may be processed by the registered EventHandler before this method has returned. If this session is using an external EventDispatcher it should be already started.

A session must only be started once.

(Inherited from IAbstractSession.)
Public methodStop (Inherited from IAbstractSession.)
Public methodStop(AbstractSessionStopOption)
Stops this session.
(Inherited from IAbstractSession.)
Public methodSubscribe(IListSubscription)
Public methodSubscribe(IListSubscription, Identity)
Public methodSubscribe(IListSubscription, SubscriptionPreprocessMode)
Public methodSubscribe(IListSubscription, String)
Public methodSubscribe(IListSubscription, Identity, SubscriptionPreprocessMode)
Public methodSubscribe(IListSubscription, Identity, String)
Initiates a request to receive asynchronous updates to the specified topics.

Upon completion of this request a SUBSCRIPTION_STATUS event will be published for each topic in the subscription list containing a message with the result for one topic. A "SubscriptionStarted" message will be generated if the subscription was successfully initiated. If the subscription fails for any topic a "SubscriptionFailure" message containing the failure reason will be generated.

Any subscriptions in subscriptionList which were not given a application generated CorrelationID will have a session generated CorrelationID set.

Multiple subscriptions to the same subscription string are valid and each will have their own, unique CorrelationID.

In the case of an exception none of the subscriptions will be processed.

Public methodSubscribe(IListSubscription, String, SubscriptionPreprocessMode)
Public methodSubscribe(IListSubscription, Identity, String, SubscriptionPreprocessMode)
Initiates a request to receive asynchronous updates to the specified topics.

Upon completion of this request a SUBSCRIPTION_STATUS event will be published for each topic in the subscription list containing a message with the result for one topic. A "SubscriptionStarted" message will be generated if the subscription was successfully initiated. If the subscription fails for any topic a "SubscriptionFailure" message containing the failure reason will be generated.

Any subscriptions in subscriptionList which were not given a application generated CorrelationID will have a session generated CorrelationID set.

Multiple subscriptions to the same subscription string are valid and each will have their own, unique CorrelationID.

Public methodTryNextEvent
Retrieves the next event available for processing on this session.

This method never blocks.

An EventHandler must not have been provided at construction.
(Inherited from IAbstractSession.)
Public methodUnsubscribe(IListSubscription)
Public methodUnsubscribe(IListSubscription, String)
Cancel a list of subscriptions.

If the CorrelationID of any entry in the list does not identify a current subscription then that entry is ignored.

See Cancel(CorrelationID) for more information on the handling of cancel requests.

Top
See Also