class IO2GTableListener

Parents
IAddRef

Brief

The interface provides method signatures to process notifications about trading tables events: adding/updating/deleting of rows, and changes in a table status.

Details

The interface can be implemented only when the application uses the IO2GTableManager.

Prerequisites

You must specify that your session uses the table manager before a login. For example,

mSession->useTableManager(Yes, NULL);

After the successful login, you must obtain an instance of the IO2GTableManager class. For example,

IO2GTableManager *tableManager = mSession->getTableManager();

The table manager keeps in memory the trading tables and therefore allows access to the up-to-date field values and ability to capture table events.
If you want to process notifications about specific table events, you must obtain an instance of the class derived from the IO2GTable class. For example, if you need information about opened positions, write the following line:

IO2GTradesTable *tradesTable = (IO2GTradesTable *)tableManager->getTable(Trades);

For complete instructions on the table manager usage, refer to the How to use table manager in ForexConnect API section.

Limitations

THe IO2GTableListener is notified only about the trading tables updates (see O2GResponseType.TablesUpdates).
Note:In order to process the response which comes as an answer to a request execution, you application needs to implement the IO2GResponseListener interface.

Implementation

If you want to use methods of the IO2GTableListener interface, you must create a class that implements the interface. For example,

class TableListener : public IO2GTableListener { }

In your application you must create an instance of the class that implements the interface. For example,

TableListener *tableListener = new TableListener();

This instance must be subscribed to a table object event.
You must subscribe to each event individually by using different methods of the IO2GTable. For example, if you want to process notifications about updates of the Trades table, call the IO2GTable.subscribeUpdate method as follows:

tradesTable->subscribeUpdate(Update, tableListener);

Before the logout, you must unsubscribe the listener from the table object. For example,

tradesTable->unsubscribeUpdate(Update, tableListener);

Examples of the subscriprion/unsubscription methods syntax are listed below. These examples are based on the Trades table.

Method name

Subscribe syntax

Unsubscribe syntax

onAdded

tradesTable.subscribeUpdate(Insert, tableListener);

tradesTable.unsubscribeUpdate(OInsert, tableListener);

onChanged

tradesTable.subscribeUpdate(Update, tableListener);

tradesTable.unsubscribeUpdate(Update, tableListener);

onDeleted

tradesTable.subscribeUpdate(Delete, tableListener);

tradesTable.unsubscribeUpdate(Delete, tableListener);

onStatusChanged

tradesTable.subscribeStatus(tableListener);

tradesTable.unsubscribeStatus(tableListener);

For the interface implementation details, see the example below:

Process notifications about opened positions [show]

Public Methods

onAdded

Processes a notification about the row addition to a table.

onChanged

Processes a notification about the row change in a table.

onDeleted

Processes a notification about the row deletion from a table.

onStatusChanged

Processes notifications about a table status changes.

back