BLPAPI C++  3.23.2
Session Class Reference

#include <blpapi_session.h>

Inheritance diagram for Session:
AbstractSession

Public Types

enum  SubscriptionStatus {
  UNSUBSCRIBED = 0,
  SUBSCRIBING = 1,
  SUBSCRIBED = 2,
  CANCELLED = 3,
  PENDING_CANCELLATION = 4
}
 
typedef ::BloombergLP::blpapi::EventHandler EventHandler
 

Public Member Functions

 Session (const SessionOptions &options=SessionOptions(), EventHandler *eventHandler=0, EventDispatcher *eventDispatcher=0)
 
 Session (blpapi_Session_t *handle)
 
virtual ~Session ()
 
virtual bool start ()
 
virtual bool startAsync ()
 
virtual void stop ()
 
virtual void stopAsync ()
 
virtual Event nextEvent (int timeout=0)
 
virtual int tryNextEvent (Event *event)
 
virtual void subscribe (const SubscriptionList &subscriptionList, const Identity &identity, const char *requestLabel=0, int requestLabelLen=0)
 
virtual SubscriptionPreprocessErrors subscribe (const SubscriptionList &subscriptionList, const Identity &identity, SubscriptionPreprocessMode::Enum mode, const char *requestLabel=0, int requestLabelLen=0)
 
virtual void subscribe (const SubscriptionList &subscriptionList, const char *requestLabel=0, int requestLabelLen=0)
 
virtual SubscriptionPreprocessErrors subscribe (const SubscriptionList &subscriptionList, SubscriptionPreprocessMode::Enum mode, const char *requestLabel=0, int requestLabelLen=0)
 
virtual void unsubscribe (const SubscriptionList &subscriptionList)
 
virtual void resubscribe (const SubscriptionList &subscriptions)
 
virtual SubscriptionPreprocessErrors resubscribe (const SubscriptionList &subscriptions, SubscriptionPreprocessMode::Enum mode)
 
virtual void resubscribe (const SubscriptionList &subscriptions, const char *requestLabel, int requestLabelLen)
 
virtual SubscriptionPreprocessErrors resubscribe (const SubscriptionList &subscriptions, const char *requestLabel, int requestLabelLen, SubscriptionPreprocessMode::Enum mode)
 
virtual void resubscribe (const SubscriptionList &subscriptions, int resubscriptionId)
 
virtual SubscriptionPreprocessErrors resubscribe (const SubscriptionList &subscriptions, int resubscriptionId, SubscriptionPreprocessMode::Enum mode)
 
virtual void resubscribe (const SubscriptionList &subscriptions, int resubscriptionId, const char *requestLabel, int requestLabelLen)
 
virtual SubscriptionPreprocessErrors resubscribe (const SubscriptionList &subscriptions, int resubscriptionId, const char *requestLabel, int requestLabelLen, SubscriptionPreprocessMode::Enum mode)
 
virtual void setStatusCorrelationId (const Service &service, const CorrelationId &correlationID)
 
virtual void setStatusCorrelationId (const Service &service, const Identity &identity, const CorrelationId &correlationID)
 
virtual CorrelationId sendRequest (const Request &request, const CorrelationId &correlationId=CorrelationId(), EventQueue *eventQueue=0, const char *requestLabel=0, int requestLabelLen=0)
 
virtual CorrelationId sendRequest (const Request &request, const Identity &user, const CorrelationId &correlationId=CorrelationId(), EventQueue *eventQueue=0, const char *requestLabel=0, int requestLabelLen=0)
 
virtual CorrelationId sendRequest (const RequestTemplate &requestTemplate, const CorrelationId &correlationId=CorrelationId())
 
virtual RequestTemplate createSnapshotRequestTemplate (const char *subscriptionString, const CorrelationId &statusCid, const Identity &identity=Identity())
 
blpapi_Session_thandle () const
 
virtual bool openService (const char *serviceIdentifier)
 
virtual CorrelationId openServiceAsync (const char *serviceIdentifier, const CorrelationId &correlationId=CorrelationId())
 
virtual CorrelationId sendAuthorizationRequest (const Request &authorizationRequest, Identity *identity, const CorrelationId &correlationId=CorrelationId(), EventQueue *eventQueue=0)
 
virtual void cancel (const CorrelationId &correlationId)
 
virtual void cancel (const std::vector< CorrelationId > &correlationIds)
 
virtual void cancel (const CorrelationId *correlationIds, size_t numCorrelationIds)
 
virtual CorrelationId generateToken (const CorrelationId &correlationId=CorrelationId(), EventQueue *eventQueue=0)
 
virtual CorrelationId generateToken (const char *userId, const char *ipAddress, const CorrelationId &correlationId=CorrelationId(), EventQueue *eventQueue=0)
 
virtual Service getService (const char *serviceIdentifier) const
 
virtual Identity createIdentity ()
 
CorrelationId generateAuthorizedIdentity (const AuthOptions &authOptions, const CorrelationId &cid=CorrelationId())
 
Identity getAuthorizedIdentity (const CorrelationId &correlationId=CorrelationId())
 
std::string sessionName ()
 
DEPRECATED
UserHandle createUserHandle ()
 

Friends

void blpapi_eventHandlerAdapter (blpapi_Event_t *event, blpapi_Session_t *, void *userData)
 

Detailed Description

This class provides a consumer session for making requests for Bloomberg 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 object is supplied when it is constructed. All incoming events are delivered to the EventHandler supplied on construction. Calls to nextEvent on an asynchronous session will fail.

A Session is synchronous if an EventHandler object is not supplied when it is constructed. The nextEvent() method must be called to read incoming events.

Several methods in Session take a CorrelationId parameter. The application may choose to supply its own CorrelationId values or allow the Session to create values. If the application supplies its own CorrelationId values it must manage their lifetime such that the same value is not reused for more than one operation at a time. The lifetime of a CorrelationId begins when it is supplied in a method invoked on a Session and ends either when it is explicitly cancelled using cancel() or unsubscribe(), when a RESPONSE Event (not a PARTIAL_RESPONSE) containing it is received or when a SUBSCRIPTION_STATUS Event which indicates that the subscription it refers to has been terminated is received.

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_STATUS Event generated by a startAsync() may be processed before startAsync() has returned (even though startAsync() itself will not block).

This becomes more significant when Session generated CorrelationIds are in use. For example, if a call to subscribe() 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 user generated CorrelationIds when using asynchronous Sessions. This issue does not arise when using a synchronous Session as long as the calls to subscribe() etc. are made on the same thread as the calls to nextEvent().

See Component blpapi_session

Member Typedef Documentation

◆ EventHandler

Member Enumeration Documentation

◆ SubscriptionStatus

Enumerator
UNSUBSCRIBED 

No longer active, terminated by API.

SUBSCRIBING 

Initiated but no updates received.

SUBSCRIBED 

Updates are flowing.

CANCELLED 

No longer active, terminated by Application.

PENDING_CANCELLATION 

Constructor & Destructor Documentation

◆ Session() [1/2]

Session ( const SessionOptions options = SessionOptions(),
EventHandler eventHandler = 0,
EventDispatcher eventDispatcher = 0 
)

Construct a Session using the optionally specified options, the optionally specified eventHandler and the optionally specified eventDispatcher.

See the SessionOptions documentation for details on what can be specified in the options.

If eventHandler is not null then this Session will operate in asynchronous mode, otherwise the Session will operate in synchronous mode.

If eventDispatcher is null then the Session will create a default EventDispatcher for this Session which will use a single thread for dispatching events. For more control over event dispatching a specific instance of EventDispatcher can be supplied. This can be used to share a single EventDispatcher amongst multiple Session objects.

If an eventDispatcher is supplied which uses more than one thread the Session will ensure that events which should be ordered are passed to callbacks in a correct order. For example, partial response to a request or updates to a single subscription.

The behavior is undefined if eventHandler is null and the eventDispatcher is not null.

Each EventDispatcher uses its own thread or pool of threads so if you want to ensure that a session which receives very large messages and takes a long time to process them does not delay a session that receives small messages and processes each one very quickly then give each one a separate EventDispatcher.

◆ Session() [2/2]

Session ( blpapi_Session_t handle)
explicit

◆ ~Session()

~Session ( )
virtual

Destructor.

Member Function Documentation

◆ cancel() [1/3]

void cancel ( const CorrelationId correlationId)
virtualinherited

If the specified correlationId identifies a current request then cancel that request.

Once this call returns the specified correlationId will not be seen in any subsequent Message obtained from a MessageIterator by calling next(). However, any Message currently pointed to by a MessageIterator when cancel() is called is not affected even if it has the specified correlationId. Also any Message where a reference has been retained by the application may still contain the correlationId. For these reasons, although technically an application is free to re-use correlationId as soon as this method returns it is preferable not to aggressively re-use correlation IDs, particularly with an asynchronous Session.

◆ cancel() [2/3]

void cancel ( const std::vector< CorrelationId > &  correlationIds)
virtualinherited

For each value in the specified correlationIds which identifies a current request then cancel that request. Any values in the specified correlationIds which do not identify a current request are ignored.

Once this call returns the specified correlationIds will not be seen in any subsequent Message obtained from a MessageIterator by calling next(). However, any Message currently pointed to by a MessageIterator when cancel() is called is not affected even if it has one of the specified correlationIds. Also any Message where a reference has been retained by the application may still contain one of the correlationIds. For these reasons, although technically an application is free to re-use any of the correlationIds as soon as this method returns it is preferable not to aggressively re-use correlation IDs, particularly with an asynchronous Session.

◆ cancel() [3/3]

void cancel ( const CorrelationId correlationIds,
size_t  numCorrelationIds 
)
virtualinherited

For each value specified correlationIds and numCorrelationIds which identifies a current request then cancel that request. Any specified CorrelationId's which do not identify a current request are ignored.

Once this call returns the specified correlationIds will not be seen in any subsequent Message obtained from a MessageIterator by calling next(). However, any Message currently pointed to by a MessageIterator when cancel() is called is not affected even if it has one of the specified correlationIds. Also any Message where a reference has been retained by the application may still contain one of the correlationIds. For these reasons, although technically an application is free to re-use any of the correlationIds as soon as this method returns it is preferable not to aggressively re-use correlation IDs, particularly with an asynchronous Session.

◆ createIdentity()

Identity createIdentity ( )
virtualinherited

Return a Identity which is valid but has not been authorized.

◆ createSnapshotRequestTemplate()

RequestTemplate createSnapshotRequestTemplate ( const char *  subscriptionString,
const CorrelationId statusCid,
const Identity identity = Identity() 
)
virtual

Create a snapshot request template for getting subscription data specified by the subscriptionString using the optionally specified identity if all the following conditions are met: the session is established, subscriptionString is a valid subscription string and statusCid is not used in this session. If one or more conditions are not met, an exception is thrown. The provided statusCid will be used for status updates about the created request template state and an implied subscription associated with it delivered by SUBSCRIPTION_STATUS events.

The benefit of the snapshot request templates is that these requests may be serviced from a cache and the user may expect to see significantly lower response time.

There are 3 possible states for a created request template: Pending, Available, and Terminated. Right after creation a request template is in the Pending state.

If a state is Pending, the user may send a request using this template but there are no guarantees about response time since cache is not available yet. Request template may transition into Pending state only from the Available state. In this case the RequestTemplatePending message is generated.

If state is Available, all requests will be serviced from a cache and the user may expect to see significantly reduced latency. Note, that a snapshot request template can transition out of the Available state concurrently with requests being sent, so no guarantee of service from the cache can be provided. Request template may transition into Available state only from the Pending state. In this case the RequestTemplateAvailable message is generated. This message will also contain information about currently used connection in the boundTo field. Note that it is possible to get the RequestTemplateAvailable message with a new connection information, even if a request template is already in the Available state.

If state is Terminated, sending request will always result in a failure response. Request template may transition into this state from any other state. This is a final state and it is guaranteed that the last message associated with the provided statusCid will be the RequestTemplateTerminated message which is generated when a request template transitions into this state. If a request template transitions into this state, all outstanding requests will be failed and appropriate messages will be generated for each request. After receiving the RequestTemplateTerminated message, statusCid may be reused.

Note that resources used by a snapshot request template are released only when request template transitions into the Terminated state or when session is destroyed. In order to release resources when request template is not needed anymore, user should call the Session::cancel(statusCid) unless the RequestTemplateTerminated message was already received due to some problems. When the last copy of a RequestTemplate object goes out of scope and there are no outstanding requests left, the snapshot request template will be destroyed automatically. If the last copy of a RequestTemplate object goes out of scope while there are still some outstanding requests left, snapshot service request template will be destroyed automatically when the last request gets a final response.

Note that it is possible to have a situation when response contains data that were sent by a backend before user actually sends a request template. For example it is possible if user requested data were already in an incoming TCP queue.

If identity is not provided, the session identity will be used if it has been authorized.

◆ createUserHandle()

UserHandle createUserHandle ( )
inherited
Deprecated:
Use createIdentity() instead.

Return a UserHandle which is valid but has not been authorized.

◆ generateAuthorizedIdentity()

CorrelationId generateAuthorizedIdentity ( const AuthOptions authOptions,
const CorrelationId cid = CorrelationId() 
)
inherited

Generates an authorized Identity with the specified AuthOptions and optionally specified cid.

The optionally specified cid is used to track Event objects generated as a result of this call. Return the actual CorrelationId object that will identify the messages associated with the generated identity.

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 session then these Events may be processed by the registered EventHandler before generateAuthorizedIdentity() has returned.

◆ generateToken() [1/2]

CorrelationId generateToken ( const CorrelationId correlationId = CorrelationId(),
EventQueue eventQueue = 0 
)
virtualinherited

Generate a token to be used for authorization. If an invalid authentication option is specified in session option or there is a failure to get authentication information based on authentication option, or if the authentication mode is MANUAL for a user or user and application authentication, then an InvalidArgumentException is thrown.

◆ generateToken() [2/2]

CorrelationId generateToken ( const char *  userId,
const char *  ipAddress,
const CorrelationId correlationId = CorrelationId(),
EventQueue eventQueue = 0 
)
virtualinherited

Generate a token to be used for authorization, using the specified userId and ipAddress. If the authentication mode is not MANUAL, if the userId or ipAddress are not valid or if there's a problem obtaining the authentication information based on the authentication options in SessionOptions, then an InvalidArgumentException is thrown.

◆ getAuthorizedIdentity()

Identity getAuthorizedIdentity ( const CorrelationId correlationId = CorrelationId())
inherited

Returns the authorized Identity associated with correlationId

A NotFoundException is thrown if there is no Identity associated with correlationId, if the associated Identity is not authorized, or if correlationId is not given and the session Identity is not authorized.

◆ getService()

Service getService ( const char *  serviceIdentifier) const
virtualinherited

Return a Service object representing the service identified by the specified serviceIdentifier

The serviceIdentifier must contain a fully qualified service name. That is, it must be of the form //<namespace>/<local-name>.

If the service identified by serviceIdentifier is not open or registered already then a NotFoundException is thrown.

◆ handle()

blpapi_Session_t * handle ( ) const

◆ nextEvent()

Event nextEvent ( int  timeout = 0)
virtual

Returns the next available Event for this session. If there is no event available this will block for up to the specified timeoutMillis milliseconds for an Event to arrive. A value of 0 for timeoutMillis (the default) indicates nextEvent() should not timeout and will not return until the next Event is available.

If nextEvent() returns due to a timeout it will return an event of type EventType::TIMEOUT.

If this is invoked on a Session which was created in asynchronous mode an InvalidStateException is thrown.

Implements AbstractSession.

◆ openService()

bool openService ( const char *  serviceIdentifier)
virtualinherited

Attempt to open the service identified by the specified serviceIdentifier and block until the service is either opened successfully or has failed to be opened. Return true if the service is opened successfully and false if the service cannot be successfully opened.

The serviceIdentifier must contain a fully qualified service name. That is, it must be of the form //<namespace>/<local-name>.

Before openService() returns a SERVICE_STATUS Event is generated. If this is an asynchronous Session then this Event may be processed by the registered EventHandler before openService() has returned.

◆ openServiceAsync()

CorrelationId openServiceAsync ( const char *  serviceIdentifier,
const CorrelationId correlationId = CorrelationId() 
)
virtualinherited

Begin the process to open the service identified by the specified serviceIdentifier and return immediately. The optional specified correlationId is used to track Events generated as a result of this call. The actual correlationId which will identify Events generated as a result of this call is returned.

The serviceIdentifier must contain a fully qualified service name. That is, it must be of the form //<namespace>/<local-name>.

The application must monitor events for a SERVICE_STATUS Event which will be generated once the service has been successfully opened or the opening has failed.

◆ resubscribe() [1/8]

void resubscribe ( const SubscriptionList subscriptions)
virtual

Modify each subscription in the specified subscriptionList to reflect the modified options specified for it.

For each entry in the subscriptionList which has a correlation ID which identifies a current subscription the modified options replace the current options for the subscription and a SUBSCRIPTION_STATUS event will be generated in the event stream before the first update based on the new options. If the correlation ID of an entry in the subscriptionList does not identify a current subscription then an exception is thrown.

◆ resubscribe() [2/8]

SubscriptionPreprocessErrors resubscribe ( const SubscriptionList subscriptions,
SubscriptionPreprocessMode::Enum  mode 
)
virtual

Modify each subscription in the specified subscriptionList to reflect the modified options specified for it.

For each entry in the subscriptionList which has a correlation ID which identifies a current subscription the modified options replace the current options for the subscription and a SUBSCRIPTION_STATUS event will be generated in the event stream before the first update based on the new options.

The specified mode is used to determine how to preprocess subscriptions. Refer to SubscriptionPreprocessMode for an explanation of the available modes.

◆ resubscribe() [3/8]

void resubscribe ( const SubscriptionList subscriptions,
const char *  requestLabel,
int  requestLabelLen 
)
virtual

Modify each subscription in the specified subscriptionList to reflect the modified options specified for it. The specified requestLabel and requestLabelLen define a string which will be recorded along with any diagnostics for this operation. There must be at least requestLabelLen printable characters at the location requestLabel.

For each entry in the subscriptionList which has a correlation ID which identifies a current subscription the modified options replace the current options for the subscription and a SUBSCRIPTION_STATUS event will be generated in the event stream before the first update based on the new options. If the correlation ID of an entry in the subscriptionList does not identify a current subscription then an exception is thrown.

◆ resubscribe() [4/8]

SubscriptionPreprocessErrors resubscribe ( const SubscriptionList subscriptions,
const char *  requestLabel,
int  requestLabelLen,
SubscriptionPreprocessMode::Enum  mode 
)
virtual

Modify each subscription in the specified subscriptionList to reflect the modified options specified for it. The specified requestLabel and requestLabelLen define a string which will be recorded along with any diagnostics for this operation. There must be at least requestLabelLen printable characters at the location requestLabel.

For each entry in the subscriptionList which has a correlation ID which identifies a current subscription the modified options replace the current options for the subscription and a SUBSCRIPTION_STATUS event will be generated in the event stream before the first update based on the new options.

The specified mode is used to determine how to preprocess subscriptions. Refer to SubscriptionPreprocessMode for an explanation of the available modes.

◆ resubscribe() [5/8]

void resubscribe ( const SubscriptionList subscriptions,
int  resubscriptionId 
)
virtual

Modify each subscription in the specified subscriptionList to reflect the modified options specified for it.

For each entry in the subscriptionList which has a correlation ID which identifies a current subscription the modified options replace the current options for the subscription and a SUBSCRIPTION_STATUS event containing the specified resubscriptionId will be generated in the event stream before the first update based on the new options. If the correlation ID of an entry in the subscriptionList does not identify a current subscription then an exception is thrown.

◆ resubscribe() [6/8]

SubscriptionPreprocessErrors resubscribe ( const SubscriptionList subscriptions,
int  resubscriptionId,
SubscriptionPreprocessMode::Enum  mode 
)
virtual

Modify each subscription in the specified subscriptionList to reflect the modified options specified for it.

For each entry in the subscriptionList which has a correlation ID which identifies a current subscription the modified options replace the current options for the subscription and a SUBSCRIPTION_STATUS event containing the specified resubscriptionId will be generated in the event stream before the first update based on the new options.

The specified mode is used to determine how to preprocess subscriptions. Refer to SubscriptionPreprocessMode for an explanation of the available modes.

◆ resubscribe() [7/8]

void resubscribe ( const SubscriptionList subscriptions,
int  resubscriptionId,
const char *  requestLabel,
int  requestLabelLen 
)
virtual

Modify each subscription in the specified subscriptionList to reflect the modified options specified for it. The specified requestLabel and requestLabelLen define a string which will be recorded along with any diagnostics for this operation. There must be at least requestLabelLen printable characters at the location requestLabel.

For each entry in the subscriptionList which has a correlation ID which identifies a current subscription the modified options replace the current options for the subscription and a SUBSCRIPTION_STATUS event containing the specified resubscriptionId will be generated in the event stream before the first update based on the new options. If the correlation ID of an entry in the subscriptionList does not identify a current subscription then an exception is thrown.

◆ resubscribe() [8/8]

SubscriptionPreprocessErrors resubscribe ( const SubscriptionList subscriptions,
int  resubscriptionId,
const char *  requestLabel,
int  requestLabelLen,
SubscriptionPreprocessMode::Enum  mode 
)
virtual

Modify each subscription in the specified subscriptionList to reflect the modified options specified for it. The specified requestLabel and requestLabelLen define a string which will be recorded along with any diagnostics for this operation. There must be at least requestLabelLen printable characters at the location requestLabel.

For each entry in the subscriptionList which has a correlation ID which identifies a current subscription the modified options replace the current options for the subscription and a SUBSCRIPTION_STATUS event containing the specified resubscriptionId will be generated in the event stream before the first update based on the new options.

The specified mode is used to determine how to preprocess subscriptions. Refer to SubscriptionPreprocessMode for an explanation of the available modes.

◆ sendAuthorizationRequest()

CorrelationId sendAuthorizationRequest ( const Request authorizationRequest,
Identity identity,
const CorrelationId correlationId = CorrelationId(),
EventQueue eventQueue = 0 
)
virtualinherited

Send the specified authorizationRequest and update the specified identity with the results. If the optionally specified correlationId is supplied, it is used; otherwise create a CorrelationId. The actual CorrelationId used is returned. If the optionally specified eventQueue is supplied all Events relating to this Request will arrive on that EventQueue.

A successful request will generate zero or more PARTIAL_RESPONSE Messages followed by exactly one RESPONSE Message. Once the final RESPONSE Message has been received the specified identity will have been updated to contain the users entitlement information and the CorrelationId associated with the request may be re-used. If the request fails at any stage a REQUEST_STATUS will be generated, the specified identity will not be modified and the CorrelationId may be re-used.

The identity supplied must have been returned from this Session's createIdentity() method. For example

Identity handle(session.createIdentity());
session.sendAuthorizationRequest(authRequest, &handle, ...)

◆ sendRequest() [1/3]

CorrelationId sendRequest ( const Request request,
const CorrelationId correlationId = CorrelationId(),
EventQueue eventQueue = 0,
const char *  requestLabel = 0,
int  requestLabelLen = 0 
)
virtual

Send the specified request. If the optionally specified correlationId is supplied use it otherwise create a CorrelationId. The actual CorrelationId used is returned. If the optionally specified eventQueue is supplied all events relating to this Request will arrive on that EventQueue. If the optional requestLabel and requestLabelLen are provided they define a string which will be recorded along with any diagnostics for this operation. There must be at least requestLabelLen printable characters at the location requestLabel.

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

The session identity will be used if it has been authorized.

◆ sendRequest() [2/3]

CorrelationId sendRequest ( const Request request,
const Identity user,
const CorrelationId correlationId = CorrelationId(),
EventQueue eventQueue = 0,
const char *  requestLabel = 0,
int  requestLabelLen = 0 
)
virtual

Send the specified request using the specified identity for authorization. If the optionally specified correlationId is supplied use it otherwise create a CorrelationId. The actual CorrelationId used is returned. If the optionally specified eventQueue is supplied all events relating to this Request will arrive on that EventQueue. If the optional requestLabel and requestLabelLen are provided they define a string which will be recorded along with any diagnostics for this operation. There must be at least requestLabelLen printable characters at the location requestLabel.

A successful request will generate zero or more PARTIAL_RESPONSE Messages followed by exactly one RESPONSE Message. Once the final RESPONSE Message 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.

◆ sendRequest() [3/3]

CorrelationId sendRequest ( const RequestTemplate requestTemplate,
const CorrelationId correlationId = CorrelationId() 
)
virtual

Send a request defined by the specified requestTemplate. If the optionally specified correlationId is supplied, use it otherwise create a new CorrelationId. The actual CorrelationId used is returned.

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.

The session identity will be used if it has been authorized.

◆ sessionName()

std::string sessionName ( )
inherited

Returns the session name.

◆ setStatusCorrelationId() [1/2]

void setStatusCorrelationId ( const Service service,
const CorrelationId correlationID 
)
virtual

◆ setStatusCorrelationId() [2/2]

void setStatusCorrelationId ( const Service service,
const Identity identity,
const CorrelationId correlationID 
)
virtual

Set the CorrelationID on which service status messages will be received. Note: No service status messages are received prior to this call

◆ start()

bool start ( )
virtual

Attempt to start this Session and block until the Session has started or failed to start. If the Session is started successfully true is returned, otherwise false is returned. Before start() returns a SESSION_STATUS Event is generated. If this is an asynchronous Session then the SESSION_STATUS may be processed by the registered EventHandler before start() has returned. A Session may only be started once.

Implements AbstractSession.

◆ startAsync()

bool startAsync ( )
virtual

Attempt to begin the process to start this Session and return true if successful, otherwise return false. The application must monitor events for a SESSION_STATUS Event which will be generated once the Session has started or if it fails to start. If this is an asynchronous Session then the SESSION_STATUS Event may be processed by the registered EventHandler before startAsync() has returned. A Session may only be started once.

Implements AbstractSession.

◆ stop()

void stop ( )
virtual

Stop operation of this session and block until all callbacks to EventHandler objects relating to this Session which are currently in progress have completed (including the callback to handle the SESSION_STATUS Event with SessionTerminated message this call generates). Once this returns no further callbacks to EventHandlers will occur. If stop() is called from within an EventHandler callback the behavior is undefined and may result in a deadlock. Once a Session has been stopped it can only be destroyed.

Implements AbstractSession.

◆ stopAsync()

void stopAsync ( )
virtual

Begin the process to stop this Session and return immediately. The application must monitor events for a SESSION_STATUS Event with SessionTerminated message which will be generated once the Session has been stopped. After this SESSION_STATUS Event no further callbacks to EventHandlers will occur. This method can be called from within an EventHandler callback to stop Sessions using non-default (external) EventDispatcher. Once a Session has been stopped it can only be destroyed.

Implements AbstractSession.

◆ subscribe() [1/4]

void subscribe ( const SubscriptionList subscriptionList,
const Identity identity,
const char *  requestLabel = 0,
int  requestLabelLen = 0 
)
virtual

Begin subscriptions for each entry in the specified subscriptionList using the specified identity for authorization. If the optional requestLabel and requestLabelLen are provided they define a string which will be recorded along with any diagnostics for this operation. There must be at least requestLabelLen printable characters at the location requestLabel.

A SUBSCRIPTION_STATUS Event will be generated for each entry in the subscriptionList.

◆ subscribe() [2/4]

SubscriptionPreprocessErrors subscribe ( const SubscriptionList subscriptionList,
const Identity identity,
SubscriptionPreprocessMode::Enum  mode,
const char *  requestLabel = 0,
int  requestLabelLen = 0 
)
virtual

Begin subscriptions for each entry in the specified subscriptionList using the specified identity for authorization.

The specified mode is used to determine how to preprocess subscriptions. Refer to SubscriptionPreprocessMode for an explanation of the available modes.

If the optional requestLabel and requestLabelLen are provided they define a string which will be recorded along with any diagnostics for this operation. There must be at least requestLabelLen printable characters at the location requestLabel.

A SUBSCRIPTION_STATUS Event will be generated for each valid subscriptions in the list.

◆ subscribe() [3/4]

void subscribe ( const SubscriptionList subscriptionList,
const char *  requestLabel = 0,
int  requestLabelLen = 0 
)
virtual

Begin subscriptions for each entry in the specified subscriptionList using the session identity information. If the optional requestLabel and requestLabelLen are provided they define a string which will be recorded along with any diagnostics for this operation. There must be at least requestLabelLen printable characters at the location requestLabel.

A SUBSCRIPTION_STATUS Event will be generated for each entry in the subscriptionList.

The session identity will be used if it has been authorized.

◆ subscribe() [4/4]

SubscriptionPreprocessErrors subscribe ( const SubscriptionList subscriptionList,
SubscriptionPreprocessMode::Enum  mode,
const char *  requestLabel = 0,
int  requestLabelLen = 0 
)
virtual

Begin subscriptions for each entry in the specified subscriptionList using the session identity information.

The specified mode is used to determine how to preprocess subscriptions. Refer to SubscriptionPreprocessMode for an explanation of the available modes.

If the optional requestLabel and requestLabelLen are provided they define a string which will be recorded along with any diagnostics for this operation. There must be at least requestLabelLen printable characters at the location requestLabel.

A SUBSCRIPTION_STATUS Event will be generated for each entry in the subscriptionList.

The session identity will be used if it has been authorized.

◆ tryNextEvent()

int tryNextEvent ( Event event)
virtual

If there are Events available for the session, load the next Event into event and return 0 indicating success. If there is no event available for the session, return a non-zero value with no effect on event. This method never blocks.

Implements AbstractSession.

◆ unsubscribe()

void unsubscribe ( const SubscriptionList subscriptionList)
virtual

Cancel each of the current subscriptions identified by the specified subscriptionList. If the correlation ID of any entry in the subscriptionList does not identify a current subscription then that entry is ignored. All entries which have valid correlation IDs will be cancelled.

Once this call returns the correlation ids in the subscriptionList will not be seen in any subsequent Message obtained from a MessageIterator by calling next(). However, any Message currently pointed to by a MessageIterator when unsubscribe() is called is not affected even if it has one of the correlation IDs in the subscriptionList. Also any Message where a reference has been retained by the application may still contain a correlation ID from the subscriptionList. For these reasons, although technically an application is free to re-use the correlation IDs as soon as this method returns it is preferable not to aggressively re-use correlation IDs, particularly with an asynchronous Session.

Friends And Related Function Documentation

◆ blpapi_eventHandlerAdapter

void blpapi_eventHandlerAdapter ( blpapi_Event_t event,
blpapi_Session_t ,
void *  userData 
)
friend

Adapter blpapi_EventHandler_t implementation that dispatches the specified event to a blpapi::Session pointed by userData.


The documentation for this class was generated from the following file: