dxFeed .Net API  7.1.0
dxFeed .Net API library intended to provide market data access for DX clients
com.dxfeed.api.DXFeedSubscription< E > Class Template Reference

Subscription for a set of symbols and event types. More...

Inheritance diagram for com.dxfeed.api.DXFeedSubscription< E >:
[legend]
Collaboration diagram for com.dxfeed.api.DXFeedSubscription< E >:
[legend]

Public Member Functions

 DXFeedSubscription (DXEndpoint endpoint)
 Creates detached subscription for a single event type. More...
 
 DXFeedSubscription (DXEndpoint endpoint, params Type[] eventTypes)
 Creates detached subscription for the given list of event types. More...
 
void Attach (IDXFeed feed)
 Attaches subscription to the specified feed. More...
 
void Detach (IDXFeed feed)
 Detaches subscription from the specified feed. More...
 
void Close ()
 
bool ContainsEventType (Type eventType)
 Returns true if this subscription contains the corresponding event type. More...
 
void Clear ()
 
ISet< object > GetSymbols ()
 Returns a set of subscribed symbols. The resulting set cannot be modified. The contents of the resulting set are undefined if the set of symbols is changed after invocation of this method, but the resulting set is safe for concurrent reads from any threads. The resulting set maybe either a snapshot of the set of the subscribed symbols at the time of invocation or a weakly consistent view of the set. More...
 
void SetSymbols (ICollection< object > symbols)
 
void SetSymbols (params object[] symbols)
 
void AddSymbols (ICollection< object > symbols)
 
void AddSymbols (params object[] symbols)
 
void AddSymbols (object symbol)
 
void RemoveSymbols (ICollection< object > symbols)
 
void RemoveSymbols (params object[] symbols)
 
void AddEventListener (IDXFeedEventListener< E > listener)
 Adds listener for events. Newly added listeners start receiving only new events. This method does nothing if this subscription is IsClosed. More...
 
void RemoveEventListener (IDXFeedEventListener< E > listener)
 Removes listener for events. More...
 

Protected Member Functions

 DXFeedSubscription (params Type[] eventTypes)
 
void AddSymbols (bool callUpdateEvent, params object[] symbols)
 
void Endpoint_OnClosing (object sender, EventArgs e)
 

Protected Attributes

IDxSubscription subscriptionInstance = null
 
List< IDXFeedEventListener< E > > eventListeners = new List<IDXFeedEventListener<E>>()
 
object eventListenerLocker = new object()
 

Properties

bool IsClosed [get]
 Returns true if this subscription is closed.

See also
Close()
More...
 
ISet< Type > EventTypes [get]
 Returns a set of subscribed event types. The resulting set cannot be modified. More...
 
- Properties inherited from com.dxfeed.api.IDXFeedSubscription< E >
bool IsClosed [get]
 Returns true if this subscription is closed.

See also
Close()
More...
 
ISet< Type > EventTypes [get]
 Returns a set of subscribed event types. The resulting set cannot be modified. More...
 

Events

DXFeedSymbolsUpdateEventHandler OnSymbolsAdded
 Event calls when any symbols is added to subscription. More...
 
DXFeedSymbolsUpdateEventHandler OnSymbolsRemoved
 Event calls when any symbols is removed from subscription. More...
 
DXFeedSubscriptionClosedEventHandler OnSubscriptionClosed
 Event calls when subscription is closing. More...
 
- Events inherited from com.dxfeed.api.IDXFeedSubscription< E >
DXFeedSymbolsUpdateEventHandler OnSymbolsAdded
 Event calls when any symbols is added to subscription. More...
 
DXFeedSymbolsUpdateEventHandler OnSymbolsRemoved
 Event calls when any symbols is removed from subscription. More...
 
DXFeedSubscriptionClosedEventHandler OnSubscriptionClosed
 Event calls when subscription is closing. More...
 

Detailed Description

Subscription for a set of symbols and event types.

Template Parameters
EThe type of events.
Type Constraints
E :IDxEventType 

Constructor & Destructor Documentation

◆ DXFeedSubscription() [1/2]

Creates detached subscription for a single event type.

Parameters
endpointThe DXEndpoint instance.
Exceptions
ArgumentNullExceptionIf endpoint is null.
ArgumentExceptionIf type E is not event class.
DxExceptionInternal error.

◆ DXFeedSubscription() [2/2]

com.dxfeed.api.DXFeedSubscription< E >.DXFeedSubscription ( DXEndpoint  endpoint,
params Type []  eventTypes 
)
inline

Creates detached subscription for the given list of event types.

Parameters
endpointThe DXEndpoint instance.
eventTypesThe list of event types.
Exceptions
ArgumentNullExceptionIf endpoint or eventTypes is null.
ArgumentExceptionIf eventTypes are empty or any type of eventTypes is not event class.
DxExceptionInternal error.

Member Function Documentation

◆ AddEventListener()

void com.dxfeed.api.DXFeedSubscription< E >.AddEventListener ( IDXFeedEventListener< E >  listener)
inline

Adds listener for events. Newly added listeners start receiving only new events. This method does nothing if this subscription is IsClosed.

Parameters
listenerThe event listener.
Exceptions
ArgumentNullExceptionIf listener is null.

Implements com.dxfeed.api.IDXFeedSubscription< E >.

◆ AddSymbols() [1/4]

void com.dxfeed.api.DXFeedSubscription< E >.AddSymbols ( ICollection< object >  symbols)
inline

Adds the specified collection of symbols to the set of subscribed symbols. To conveniently add one or few symbols you can use AddSymbols(object[]) method. All registered event listeners will receive update on the last events for all newly added symbols.

Implementation notes.

This method notifies all subscribed OnSymbolsAdded events on symbols changing for this subscription.

Parameters
symbolsSymbols the collection of symbols.

Implements com.dxfeed.api.IDXFeedSubscription< E >.

◆ AddSymbols() [2/4]

void com.dxfeed.api.DXFeedSubscription< E >.AddSymbols ( params object []  symbols)
inline

Adds the specified array of symbols to the set of subscribed symbols. This is a convenience method to subscribe to one or few symbols at a time. When subscribing to multiple symbols at once it is preferable to use AddSymbols(ICollection<object>) method. All registered event listeners will receive update on the last events for all newly added symbols.

Implementation notes.

This method notifies all subscribed OnSymbolsAdded events on symbols changing for this subscription.

Parameters
symbolsThe array of symbols.

Implements com.dxfeed.api.IDXFeedSubscription< E >.

◆ AddSymbols() [3/4]

void com.dxfeed.api.DXFeedSubscription< E >.AddSymbols ( object  symbol)
inline

Adds the specified symbol to the set of subscribed symbols. This is a convenience method to subscribe to one symbol at a time that has a return fast-path for a case when the symbol is already in the set. When subscribing to multiple symbols at once it is preferable to use AddSymbols(ICollection<object>) method. All registered event listeners will receive update on the last events for all newly added symbols.

Implementation notes.

This method notifies all subscribed OnSymbolsAdded events on symbols changing for this subscription.

Parameters
symbolThe symbol.

Implements com.dxfeed.api.IDXFeedSubscription< E >.

◆ AddSymbols() [4/4]

void com.dxfeed.api.DXFeedSubscription< E >.AddSymbols ( bool  callUpdateEvent,
params object []  symbols 
)
inlineprotected

Adds the specified array of symbols to the set of subscribed symbols. This is a convenience method to subscribe to one or few symbols at a time. When subscribing to multiple symbols at once it is preferable to use AddSymbols(ICollection<object>) method. All registered event listeners will receive update on the last events for all newly added symbols.

Implementation notes.

This method notifies all subscribed OnSymbolsAdded events on symbols changing for this subscription. The false value of callUpdateEvent disables calling any symbols update events for this method.

Parameters
callUpdateEventThe false value disables calling any symbols update events for this method.
symbolsThe array of symbols.

◆ Attach()

void com.dxfeed.api.DXFeedSubscription< E >.Attach ( IDXFeed  feed)
inline

Attaches subscription to the specified feed.

Parameters
feedFeed to attach to.

Implements com.dxfeed.api.IDXFeedSubscription< E >.

◆ Clear()

void com.dxfeed.api.DXFeedSubscription< E >.Clear ( )
inline

Clears the set of subscribed symbols.

Implementation notes.

This method notifies all subscribed OnSymbolsRemoved events on clear symbols from this subscription.

Implements com.dxfeed.api.IDXFeedSubscription< E >.

◆ Close()

void com.dxfeed.api.DXFeedSubscription< E >.Close ( )
inline

Closes this subscription and makes it permanently detached. This method notifies attached IDXFeed by invoking Detach(IDXFeed) and IDXFeed.DetachSubscription<E>(IDXFeedSubscription<E>) methods while holding the lock for this subscription. This method clears lists of all installed event listeners and subscription change listeners and makes sure that no more listeners can be added.

This method ensures that subscription can be safely garbage-collected when all outside references to it are lost.

Implements com.dxfeed.api.IDXFeedSubscription< E >.

◆ ContainsEventType()

bool com.dxfeed.api.DXFeedSubscription< E >.ContainsEventType ( Type  eventType)
inline

Returns true if this subscription contains the corresponding event type.

Parameters
eventTypeType of event.
Returns
True if this subscription contains the corresponding event type.

Implements com.dxfeed.api.IDXFeedSubscription< E >.

◆ Detach()

void com.dxfeed.api.DXFeedSubscription< E >.Detach ( IDXFeed  feed)
inline

Detaches subscription from the specified feed.

Parameters
feedFeed to detach from.

Implements com.dxfeed.api.IDXFeedSubscription< E >.

◆ GetSymbols()

ISet<object> com.dxfeed.api.DXFeedSubscription< E >.GetSymbols ( )
inline

Returns a set of subscribed symbols. The resulting set cannot be modified. The contents of the resulting set are undefined if the set of symbols is changed after invocation of this method, but the resulting set is safe for concurrent reads from any threads. The resulting set maybe either a snapshot of the set of the subscribed symbols at the time of invocation or a weakly consistent view of the set.

Returns
Set of subscribed symbols.

Implements com.dxfeed.api.IDXFeedSubscription< E >.

◆ RemoveEventListener()

void com.dxfeed.api.DXFeedSubscription< E >.RemoveEventListener ( IDXFeedEventListener< E >  listener)
inline

Removes listener for events.

Parameters
listenerListener the event listener.
Exceptions
ArgumentNullExceptionIf listener is null.

Implements com.dxfeed.api.IDXFeedSubscription< E >.

◆ RemoveSymbols() [1/2]

void com.dxfeed.api.DXFeedSubscription< E >.RemoveSymbols ( ICollection< object >  symbols)
inline

Removes the specified collection of symbols from the set of subscribed symbols. To conveniently remove one or few symbols you can use RemoveSymbols(object[]) method.

Implementation notes.

This method notifies all subscribed OnSymbolsRemoved events on symbols changing for this subscription.

Parameters
symbolsThe collection of symbols.

Implements com.dxfeed.api.IDXFeedSubscription< E >.

◆ RemoveSymbols() [2/2]

void com.dxfeed.api.DXFeedSubscription< E >.RemoveSymbols ( params object []  symbols)
inline

Removes the specified array of symbols from the set of subscribed symbols. This is a convenience method to remove one or few symbols at a time. When removing multiple symbols at once it is preferable to use RemoveSymbols(ICollection<object>) method.

Implementation notes.

This method notifies all subscribed OnSymbolsRemoved events on symbols changing for this subscription.

Parameters
symbolsThe array of symbols.

Implements com.dxfeed.api.IDXFeedSubscription< E >.

◆ SetSymbols() [1/2]

void com.dxfeed.api.DXFeedSubscription< E >.SetSymbols ( ICollection< object >  symbols)
inline

Changes the set of subscribed symbols so that it contains just the symbols from the specified collection. To conveniently set subscription for just one or few symbols you can use SetSymbols(object[]) method. All registered event listeners will receive update on the last events for all newly added symbols.

Implementation notes.

This method notifies all subscribed OnSymbolsAdded and OnSymbolsRemoved events on symbols changing for this subscription.

Parameters
symbolsThe collection of symbols.

Implements com.dxfeed.api.IDXFeedSubscription< E >.

◆ SetSymbols() [2/2]

void com.dxfeed.api.DXFeedSubscription< E >.SetSymbols ( params object []  symbols)
inline

Changes the set of subscribed symbols so that it contains just the symbols from the specified array. This is a convenience method to set subscription to one or few symbols at a time. When setting subscription to multiple symbols at once it is preferable to use SetSymbols(ICollection<object>) method. All registered event listeners will receive update on the last events for all newly added symbols.

Implementation notes.

This method notifies all subscribed OnSymbolsAdded and OnSymbolsRemoved events on symbols changing for this subscription.

Parameters
symbolsThe array of symbols.

Implements com.dxfeed.api.IDXFeedSubscription< E >.

Property Documentation

◆ EventTypes

ISet<Type> com.dxfeed.api.DXFeedSubscription< E >.EventTypes
get

Returns a set of subscribed event types. The resulting set cannot be modified.

◆ IsClosed

bool com.dxfeed.api.DXFeedSubscription< E >.IsClosed
get

Returns true if this subscription is closed.

See also
Close()

Event Documentation

◆ OnSubscriptionClosed

Event calls when subscription is closing.

◆ OnSymbolsAdded

Event calls when any symbols is added to subscription.

◆ OnSymbolsRemoved

Event calls when any symbols is removed from subscription.


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