class IO2GResponse

Parents
IAddRef

Brief

The class contains a response received from the trading server.

Details

There are two types of responses:

The way a response object is processed depends on the response type.

Processing user request responses

To process notifications about a request answer, an instance of the class implementing the IO2GResponseListener interface must be subscribed to a session object by using the subscribeResponse method.
Requests may be successfully completed or may fail.
To process notifications about successful request completions, you must use the IO2GResponseListener.onRequestCompleted method.
To process notifications about request failures, you must use the IO2GResponseListener.onRequestFailed method.

The type of a response depends on the request type. To find out the type of your response, use the getType method of the IO2GResponse class.
To process the contents of a response object, you must use an appropriate reader based on the response type. Readers can be created by using methods of the IO2GResponseReaderFactory class.
For the list of the response types, their appropriate readers, and methods required to create them, see the table below:

O2GResponseType

Appropriate reader

O2GResponseReaderFactory method

GetAccounts

IO2GAccountsTableResponseReader

createAccountsTableReader

GetOffers

IO2GOffersTableResponseReader

createOffersTableReader

GetTrades

IO2GTradesTableResponseReader

createTradesTableReader

GetClosedTrades

IO2GClosedTradesTableResponseReader

createClosedTradesTableReader

GetMessages

IO2GMessagesTableResponseReader

createMessagesTableReader

GetOrders

IO2GOrdersTableResponseReader

createOrdersTableReader

GetSystemProperties

IO2GSystemPropertiesReader

createSystemPropertiesReader

MarketDataSnapshot

IO2GMarketDataSnapshotResponseReader

createMarketDataSnapshotReader

CreateOrderResponse

IO2GOrderResponseReader

createOrderResponseReader

Processing tables updates responses

In order to receive notifications about a table updates, you must request the information about the table first. After successful completion of the initial request, responses of the TablesUpdates type are sent automatically each time the table data are changed on the server.
For example, if you want to receive open positions updates, you must first send a request to get the initial open position information.

O2GRequest request = requestFactory.createRefreshTableRequest(Trades);

After successful completion of this request, you receive all updates of the Trades table automatically.

To process notifications about tables updates, an instance of the class implementing the IO2GResponseListener interface must be subscribed to a session object by using the subscribeResponse method.
You must process these notifications by using the IO2GResponseListener.onTablesUpdates method.

To process the contents of a response object, you must use an instance of the IO2GTablesUpdatesReader class. To create an instance of the reader, use the createTablesUpdatesReader method.

Note: If your application uses the IO2GTableManager, processing of tables updates is done in methods of the class that implements the IO2GTableListener interface.

Public Methods

getRequestID

Gets the identifier of the corresponding request.

getType

Gets the response type.

back