Implement the member execute() of each class you derive from ostc_ServerOperation. The protocol for this function is defined by ostc_ServerOperation::execute(). The Server calls execute() whenever the thin client calls ostc_Session::doOperation().
The function must extract the arguments by calling a get-value member of ostc_Object on Arguments, for each attribute of Arguments. It must then process the arguments and set the result (in the form of C++ objects) by performing members of ostc_OperationResult on result.
void txfer_operation::execute( ostc_Object * Arguments, ostc_OperationResult* result ) { const char* from_acct_name = Arguments->getStringValue("from_acct_name"); const char* to_acct_name = Arguments->getStringValue("to_acct_name"); float amount = Arguments->getFloatValue("amount"); Account * from_account = _app->getAccount(from_acct_name); Account * to_account = _app->getAccount(to_acct_name); _app->transfer(from_account, to_account, amount); os_collection *new_balances = &os_collection::create( os_segment::get_transient_segment() ); new_balances->insert( from_account ); new_balances->insert( to_account ); result->setReturnValue(new_balances); }
This example passes an os_collection* to ostc_OperationResult::setReturnValue(). The collection has two elements, a pointer to the balance of the account from which the transfer was made, and a pointer to the balance of the account to which the transfer was made.
You can also pass a void* or an os_cursor* to setReturnValue().
Click here for the example in context.