public method IO2GTableListener.onAdded

Brief

Processes a notification about the row addition to a table.

Declaration
C#
void  onAdded (string rowID, O2GRow rowData)

Parameters
rowID

The identifier of the row. The parameter has the value of the row identifier for a specific trading table. For example, for the Accounts table, it has the value of the AccountID field. The complete list of the identifiers is shown below.

rowData

The object representing a row of a table. In order to process the parameter, you need to know what table it belongs to. It can be accomplished by calling the O2GRow.TableType method. After that, you must cast the parameter to an appropriate class. For example, for a row of the Accounts table, use the O2GAccountTableRow class. The complete list of the classes is shown below.

Details

Table name

rowID

Cast rowData to

Casting syntax

Accounts

AccountID

O2GAccountTableRow

O2GAccountTableRow row = (O2GAccountTableRow)(rowData);

Offers

OfferID

O2GOfferTableRow

O2GOfferTableRow row = (O2GOfferTableRow)(rowData);

Trades

TradeID

O2GTradeTableRow

O2GTradeTableRow row = (O2GTradeTableRow)(rowData);

ClosedTrades

TradeID

O2GClosedTradeTableRow

O2GClosedTradeTableRow row = (O2GClosedTradeTableRow)(rowData);

Orders

OrderID

O2GOrderTableRow

O2GOrderTableRow row = (O2GOrderTableRow)(rowData);

Messages

MsgID

O2GMessageTableRow

O2GMessageTableRow row = (O2GMessageTableRow)(rowData);

Summary

OfferID

O2GSummaryTableRow

O2GSummaryTableRow row = (O2GSummaryTableRow)(rowData);

To get notifications about row additions to a specific table, an instance of the class implementing the IO2GTableListener interface must be subscribed to the Insert operation of this table. It is accomplished by calling the O2GTable.subscribeUpdate method with the O2GTableUpdateType.Insert parameter. For example, if you want to get notifications about the inserts into the Trades table, write the following line:

tradesTable.subscribeUpdate(O2GTableUpdateType.Insert, tableListener);

For the implementation details, see the example below: Example

Process a notification about inserts into the Trades table [hide]

// Create session which uses table manager
mSession = O2GTransport.createSession();
mSession.useTableManager(O2GTableManagerMode.Yes, null);
 
//...
// After the login, get instances of the table manager and Trades table
O2GTableManager tableManager = mSession.getTableManager();
O2GTradesTable tradesTable = (O2GTradesTable)tableManager.getTable(O2GTableType.Trades);
 
// ...
// Subscribe listener, listen to inserts into the Trades table, unsubscribe listener
TableListener tableListener = new TableListener();
tradesTable.subscribeUpdate(O2GTableUpdateType.Insert, tableListener);
Thread.Sleep(1000);
offersTable.unsubscribeUpdate(O2GTableUpdateType.Insert, tableListener);
 
// Implementation of IO2GTableListener interface public method onAdded
public void onAdded(String rowID, O2GRow rowData) {
    O2GTradeTableRow trade = (O2GTradeTableRow)(rowData);
    Console.WriteLine("Trade information added " + rowID);
    Console.WriteLine("TradeID: " + trade.TradeID +
                       " Close = " + trade.Close);
}

Declared in IO2GTableListener

back