The class provides access to a message that is intended for the user.
Method/Use |
Prerequisites |
O2GMessagesTableResponseReader .getRow
This method is used to get an initial message after a session with the trading server is established.
This method provides access to a single message. To get multiple messages, call this method in a loop. |
The Messages table is always loaded by the server automatically during a login process.
You can get the message information by using the
O2GLoginRules .getTableRefreshResponse method.
The returned O2GResponse object is of the
O2GResponseType .GET_MESSAGES type.
You must parse this object by using the O2GMessagesTableResponseReader object.
For details, see the example below. |
O2GTablesUpdatesReader .getMessageRow
This method is used to get information about a message received during a session lifetime.
This method provides access to a single message. To track multiple messages, call this method in a loop. |
To receive the message information, you must implement the IO2GResponseListener .onTablesUpdates method.
The received O2GResponse object is of the O2GResponseType .TABLES_UPDATES type.
You must parse this object by using the O2GTablesUpdatesReader object.
For details, see the example below. |
Get Messages information [hide]
// Get messages information
public static void getMessages(O2GSession session, ResponseListener responseListener) {
try {
O2GLoginRules loginRules = session.getLoginRules();
if (loginRules != null && loginRules.isTableLoadedByDefault(O2GTableType.MESSAGES)) {
O2GResponse messagesResponse = loginRules.getTableRefreshResponse(O2GTableType.MESSAGES);
O2GResponseReaderFactory responseFactory = session.getResponseReaderFactory();
if (responseFactory == null) {
return;
}
O2GMessagesTableResponseReader messagesReader = responseFactory.createMessagesTableReader(messagesResponse);
for (int i = 0; i < messagesReader.size(); i++) {
O2GMessageRow message = messagesReader.getRow(i);
System.out.println(" This is a received message: \nFrom:= " + message.getFrom() +
" Subject = " + message.getSubject() +
" Text = " + message.getText());
}
}
} catch (Exception e) {
System.out.println("Exception in getMessages().\n\t " + e.getMessage());
}
}
// Implementation of IO2GResponseListener interface public method onTablesUpdates
public void onTablesUpdates(O2GResponse response) {
O2GResponseReaderFactory factory = mSession.getResponseReaderFactory();
if (factory == null) {
return;
}
O2GTablesUpdatesReader updatesReader = factory.createTablesUpdatesReader(response);
for (int i = 0; i < updatesReader.size(); i++) {
O2GTableType tableType = updatesReader.getUpdateTable(i);
if (tableType == O2GTableType.MESSAGES) {
O2GMessageRow message = updatesReader.getMessageRow(i);
System.out.println(" This is a live message: \nFrom:= " + message.getFrom() +
" Subject = " + message.getSubject() +
" Text = " + message.getText());
}
}
}
Public Methods |
getCell
|
Gets a cell of the table.
|
getColumns
|
Gets the columns of the table.
|
getFeature
|
Gets the type of the message content.
|
getFrom
|
Gets the login of the message sender.
|
getHTMLFragmentFlag
|
Gets the flag indicating whether the message is in the HTML format or not.
|
getMsgID
|
Gets the unique identification number of the message.
|
getSubject
|
Gets the subject of the message.
|
getTableType
|
Gets the type of the table.
|
getText
|
Gets a text body of the message.
|
getTime
|
Gets the date and time when the recipient receives the message.
|
getType
|
Gets the message container.
|
isCellChanged
|
Gets a flag indicating whether the value of the cell is changed.
|