dxFeed .Net API
5.13.0
dxFeed .Net API library intended to provide market data access for DX clients
|
Connects to an instrument profile URL and reads instrument profiles using Simple File Format with support of streaming live updates. Please see Instrument Profile Format documentation for complete description. More...
Public Member Functions | |
delegate void | OnErrorEventHandler (object sender, ErrorEventArgs e) |
InstrumentProfileConnection (string address) | |
Creates instrument profile connection with a specified address. Address may be just "<host>:<port>" of server, URL, or a file path. The "[update=<period>]" clause can be optionally added at the end of the address to specify an UpdatePeriod via an address string. Default update period is 1 minute. Connection needs to be started to begin an actual operation. More... | |
void | Start () |
Starts this instrument profile connection. This connection's state immediately changes to State.Connecting and the actual connection establishment proceeds in the background. More... | |
void | Close () |
Closes this instrument profile connection. This connection's state immediately changes to State.Closed and the background update procedures are terminated. More... | |
void | AddUpdateListener (InstrumentProfileUpdateListener listener) |
Adds listener that is notified about any updates in the set of instrument profiles. If a set of instrument profiles is not empty, then this listener is immediately notified right from inside this add method. More... | |
void | RemoveUpdateListener (InstrumentProfileUpdateListener listener) |
Removes listener that is notified about any updates in the set of instrument profiles. More... | |
override string | ToString () |
Returns a string representation of the object. More... | |
Properties | |
long | UpdatePeriod [get, set] |
Gets or sets update period in milliseconds. It is period of an update check when the instrument profiles source does not support live updates and/or when connection is dropped. Default update period is 1 minute. More... | |
State | CurrentState [get] |
Returns state of this instrument profile connections. More... | |
DateTime | LastModified [get, set] |
Get or set modification time of instrument profiles or DateTime.MinValue if it is unknown. More... | |
Events | |
OnErrorEventHandler | OnError |
Private Types | |
enum | State { State.NotConnected, State.Connecting, State.Connected, State.Completed, State.Closed } |
Instrument profile connection state. More... | |
Private Member Functions | |
void | Handler () |
Method of worker thread. Runs downloading process by specified update period. More... | |
void | MakeConnected () |
Change connection status to connected. More... | |
void | MakeComplete () |
Change connection status to completed. More... | |
void | Download () |
Opens (or keeps) connection for receiving instrument profiles from server. More... | |
void | Process (Stream inputStream) |
Instrument profiles parser operations. More... | |
void | Flush (object sender, EventArgs e) |
Sends updates to listeners. More... | |
void | Complete (object sender, EventArgs e) |
Set status of completed snapshot and sends updates to listeners. More... | |
void | CallListeners (ICollection< InstrumentProfile > instrumentProfiles) |
Iterate through listeners and call them. More... | |
void | CallOnError (Exception e) |
Call error listener. More... | |
Static Private Member Functions | |
static void | CheckAndCallListener (InstrumentProfileUpdateListener listener, ICollection< InstrumentProfile > instrumentProfiles) |
Check that instrument profiles update is not empty and call listener. More... | |
Private Attributes | |
const string | UpdatePattern = "(.*)\\[update=([^\\]]+)\\]" |
const long | DefaultUpdatePeriod = 60000 |
State | state = State.NotConnected |
long | updatePeriod = DefaultUpdatePeriod |
readonly string | address |
readonly object | stateLocker = new object() |
readonly object | lastModifiedLocker = new object() |
readonly object | listenersLocker = new object() |
WebResponse | webResponse |
readonly object | webResponseLocker = new object() |
Thread | handlerThread |
Working thread to download instruments. Thread must != null when state in (CONNECTING, CONNECTED, COMPLETE). More... | |
DateTime | lastModified = DateTime.MinValue |
bool | supportsLive |
readonly List< InstrumentProfileUpdateListener > | listeners = new List<InstrumentProfileUpdateListener>() |
readonly List< InstrumentProfile > | ipBuffer = new List<InstrumentProfile>() |
readonly InstrumentProfileUpdater | updater = new InstrumentProfileUpdater() |
Connects to an instrument profile URL and reads instrument profiles using Simple File Format with support of streaming live updates. Please see Instrument Profile Format documentation for complete description.
The key different between this class and InstrumentProfileReader is that the later just reads a snapshot of a set of instrument profiles, while this classes allows to track live updates, e.g. addition and removal of instruments.
To use this class you need an address of the data source from you data provider. The name of the IPF file can also serve as an address for debugging purposes.
The recommended usage of this class to receive a live stream of instrument profile updates is:
If long-running processing of instrument profile is needed, then it is better to use InstrumentProfileUpdateListener.InstrumentProfilesUpdated notification to schedule processing task in a separate thread.
This class is thread-safe.
|
strongprivate |
Instrument profile connection state.
Enumerator | |
---|---|
NotConnected | Instrument profile connection is not started yet. InstrumentProfileConnection.Start() was not invoked yet. |
Connecting | Connection is being established. |
Connected | Connection was established. |
Completed | Initial instrument profiles snapshot was fully read (this state is set only once). |
Closed | Instrument profile connection was closed. |
|
inline |
Creates instrument profile connection with a specified address. Address may be just "<host>:<port>" of server, URL, or a file path. The "[update=<period>]" clause can be optionally added at the end of the address to specify an UpdatePeriod via an address string. Default update period is 1 minute. Connection needs to be started to begin an actual operation.
address | Address of server |
|
inline |
Adds listener that is notified about any updates in the set of instrument profiles. If a set of instrument profiles is not empty, then this listener is immediately notified right from inside this add method.
listener | Profile update listener. |
ArgumentNullException | If listener is null. |
|
inlineprivate |
Iterate through listeners and call them.
instrumentProfiles |
|
inlineprivate |
Call error listener.
e | Exception object. |
|
inlinestaticprivate |
Check that instrument profiles update is not empty and call listener.
listener | Listener to call. |
instrumentProfiles | Instrument profiles updates. |
|
inline |
Closes this instrument profile connection. This connection's state immediately changes to State.Closed and the background update procedures are terminated.
|
inlineprivate |
Set status of completed snapshot and sends updates to listeners.
sender | |
e |
|
inlineprivate |
Opens (or keeps) connection for receiving instrument profiles from server.
|
inlineprivate |
Sends updates to listeners.
sender | |
e |
|
inlineprivate |
Method of worker thread. Runs downloading process by specified update period.
|
inlineprivate |
Change connection status to completed.
|
inlineprivate |
Change connection status to connected.
delegate void com.dxfeed.ipf.live.InstrumentProfileConnection.OnErrorEventHandler | ( | object | sender, |
ErrorEventArgs | e | ||
) |
|
inlineprivate |
Instrument profiles parser operations.
inputStream | Decompressed input stream of instrument profiles. |
|
inline |
Removes listener that is notified about any updates in the set of instrument profiles.
listener | Profile update listener. |
ArgumentNullException | If listener is null. |
|
inline |
Starts this instrument profile connection. This connection's state immediately changes to State.Connecting and the actual connection establishment proceeds in the background.
|
inline |
Returns a string representation of the object.
|
private |
|
private |
|
private |
Working thread to download instruments. Thread must != null when state in (CONNECTING, CONNECTED, COMPLETE).
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
getprivate |
Returns state of this instrument profile connections.
|
getsetprivate |
Get or set modification time of instrument profiles or DateTime.MinValue if it is unknown.
|
getset |
Gets or sets update period in milliseconds. It is period of an update check when the instrument profiles source does not support live updates and/or when connection is dropped. Default update period is 1 minute.
OnErrorEventHandler com.dxfeed.ipf.live.InstrumentProfileConnection.OnError |