The sample contains a server application (MtFeedServer.exe) which emulates a real-time data feed. The application periodically reads lines of canned data from a file and posts them to all listening clients.
The application's user interface allows the user to select a file containing canned data, and run it either at the original speed, or at a ratio of the original speed.
A data file is expected to be a tab-separated text file. The top line should contain tab-separated field names. Included among the headings should be the required fields "TOPIC" and "TIME". Thus a file containing bid & ask prices might contain the following headings:
TOPIC | TIME | BID | ASK |
Each subsequent line of the file should contain field values matching those in the header line. For example:
TOPIC | TIME | BID | ASK |
ABGX | 08-Oct-2001 12:04:38 | 21.04 | 21.06 |
ENR | 08-Oct-2001 12:04:40 | 0.025 | 0.035 |
The data packets passed from server to client consist of two strings, a topic and a field list. The fields in the list are space-separated name-value pairs. For the example data shown above, the data packets would be:
Topic | Field list |
---|---|
ABGX | BID 21.04 ASK 21.06 |
ENR | BID 0.025 ASK 0.035 |
The user can specify a speed ratio for the play-back of stored data. In the example above the two data items would normally be broadcast 2 seconds apart. If the ratio is set to 2, then they will be broadcast 1 second apart. If the ratio is set to 0.1, then they will be broadcast 20 seconds apart.
The server supports an Advise/Unadvise protocol. An example exchange is shown below.
Client | Server | ||
---|---|---|---|
Initialize | The client opens a channel to the server, and registers a callback function, mtcMessageHandler(). | ||
Advise("IBM") | The client requests that all data for "IBM" be sent whenever it changes. | ||
SendData("IBM") | The server receives new data about "IBM" and sends it to the client. | ||
mtcMessageHandler("IBM") | The client's call-back function is invoked. The client stores the data and responds appropriately. | ||
Unadvise("IBM") | The client requests that no further data be sent for "IBM". | ||
SendData("IBM") | The server receives new data about "IBM" but does not send it to the client, since the client is no longer interested. | ||
Terminate | The client closes its channel to the server. |