Application Programming Interfaces
RTR C++
Object-Oriented
Programming
Interface
You can use the object-oriented programming interface to write
C++ applications that use RTR. For more information on the C++
object-oriented programming interface, refer to the
HP Reliable
Transaction Router C++ Foundation Classes
manual and the
HP
Reliable Transaction Router Application Design Guide
.
Sample C++ client
code
The following example illustrates object creation in a program
that is to act as an RTR client application. The
fi
rst step is to
create a Transaction Controller. This is followed by creating
an RTR Data Object that will hold the ASCII message for the
server, sending the message to the server application, and
fi
nally
accepting the transaction.
//
// Create a Transaction Controller to receive incoming messages
// and events from a client.
//
RTRClientTransactionController *pTransaction = new RTRClientTransactionController();
//
// Create an RTRData object to hold an ASCII message for the server.
//
RTRData *pMessage1 = new RTRData("You are pretty easy to use!!!");
//
// Send the Server a message
//
sStatus = pTransaction->SendApplicationMessage(pMessage1);
ASSERT(RTR_STS_OK == sStatus);
//
// Since we have successfully finished our work, tell RTR we accept the
// transaction.
//
pTransaction->AcceptTransaction();
Sample C++
server code
The following example illustrates creation of an object in a server
application that is to act as an RTR server. First it creates a key
segment for a speci
fi
c range of ASCII values (A to L) and creates
a data object to hold each incoming message or event. Then it
loops continuously, receiving messages and dispatching them to
the handlers.
4–18 RTR Interfaces