NOTE
MRemoteCaller is not multithread safe. Only one thread can operate on a single caller instance at a time.
To define a caller, you:

In the declaration for your caller class:
class TAdditionCaller : public MRemoteCaller, public MAdditionProtocol {
public:
TaligentTypeExtensionDeclarationsMacro(TAdditionCaller)
public:
TAdditionCaller(const TServiceReference& serviceReference);
TAdditionCaller(const TAdditionCaller& source);
virtual ~TAdditionCaller();
virtual TStream& operator>>=(TStream& toStream) const;
virtual TStream& operator<<=(TStream& fromStream);
virtual long Add(long num1, long num2);
virtual void AddOne(long& num);
MRemoteCallerDeclarationsMacro(TAdditionDispatcher);
private:
TAdditionCaller();
TAdditionCaller&operator=(const TAdditionCaller& source);
private:
enum {kOriginalVersion};
TServiceReference* fServiceReference;
TMessageStreamsTransport*fTransport;
};
TAdditionCaller::TAdditionCaller(const TServiceReference& serviceReference)
: MRemoteCaller(),
MAdditionProtocol(),
fServiceReference(NIL),
fTransport(NIL)
{
MRemoteCallerEnable();
fServiceReference = ::Copy(serviceReference);
fTransport =
new TMessageStreamsTransport (new TRequestSenderStream(*fServiceReference));
SetTransport(fTransport);
}
In the caller stub:
long
TAdditionCaller::Add(long num1, long num2)
{
long result = 0;
try {
TStream& argumentStream = *BeginRequest(TAdditionDispatcher::kAdd);
num1 >>= argumentStream;
num2 >>= argumentStream;
TStream& resultStream = *SendRequest();
result <<= resultStream;
EndRequest();
}
catch (TRemoteCallException& exception) {
cout << endl << "*** Remote call failed. ***" << endl;
}
catch (TMathException& exception) {
cout << endl << "*** Received Math Exception ***" << endl;
throw;
}
catch (TStandardException& exception) {
cout << endl
<< "*** Encountered an error while making remote call. ***" << endl;
}
catch (...) {
cout << endl
<< "*** Encountered a completely unknown error while making remote call.***"
<< endl;
}
return result;
}
MRemoteCallerDefinitionsMacro(TAdditionCaller)