GCF LOGO VCL LOGO

Make calls on methods in a remote object. More...

#include <GCF3/IpcCall>

Signals

virtual void done (bool success)
 

Public Member Functions

 IpcCall (const QHostAddress &addr, quint16 port, const QString &object, const QString &method, const QVariantList &arguments, QObject *parent=0)
 
 ~IpcCall ()
 
QHostAddress address () const
 
quint16 port () const
 
QString object () const
 
QString method () const
 
QVariantList arguments () const
 
bool isDone () const
 
bool isSuccess () const
 
QString errorMessage () const
 
QVariant result () const
 
void setTimeoutDuration (int val)
 
bool waitForDone ()
 
void setAutoDelete (bool val)
 
bool isAutoDelete () const
 

Detailed Description

You can use this class to asynchronously invoke a service method on a remote object and respond to its result when signalled. Each instance of this class can be used to make only one service call. Example

QHostAddress addr = ...;
quint16 port = ...;
GCF::IpcCall *call = new GCF::IpcCall(addr, port, "Application.MyService",
"method1", QVariantList() << ... << ...);
connect(call, SIGNAL(done(bool)), ..., SLOT(callDone(bool)));
void abcd::callDone(bool val) {
GCF::IpcCall *call = qobject_cast<GCF::IpcCall *>(this->sender());
if(val) {
QVariant result = call->result();
} else {
QString errMsg = call->errorMessage();
// Display errMsg
}
}

Constructor & Destructor Documentation

GCF::IpcCall::IpcCall ( const QHostAddress &  addr,
quint16  port,
const QString &  object,
const QString &  method,
const QVariantList &  args,
QObject *  parent = 0 
)

Constructor

Parameters
addraddress of the computer where the remote application is running
portport number on which the remote application's GCF::IpcServer is listening
objectname of the object that contains the method
methodservice method that needs to be invoked
argslist of arguments that the method accepts
parenta QObject that would become the parent of this class

By the time the constructor returns, the call will have been scheduled.

GCF::IpcCall::~IpcCall ( )

Destructor

Member Function Documentation

QHostAddress GCF::IpcCall::address ( ) const
Returns
address of the computer on which the remote application is running
quint16 GCF::IpcCall::port ( ) const
Returns
port number of the remote application's GCF::IpcServer
QString GCF::IpcCall::object ( ) const
Returns
name of the object whose method this class is calling
QString GCF::IpcCall::method ( ) const
Returns
name of the service method that is being called
QVariantList GCF::IpcCall::arguments ( ) const
Returns
list of arguments passed to the service method
bool GCF::IpcCall::isDone ( ) const
Returns
true if the call has been sent and the response has been received. False otherwise
bool GCF::IpcCall::isSuccess ( ) const
Returns
true if the call was successfully made and response was received with no error. False otherwise.
QString GCF::IpcCall::errorMessage ( ) const
Returns
if isSuccess() returns false, then this function returns an error message describing what went wrong.
QVariant GCF::IpcCall::result ( ) const
Returns
value returned by the remote method. If the remote method returned a GCF::Result, then the value returned by this function would be the data ( GCF::Result::data() ) component of the GCF::Result.
void GCF::IpcCall::setTimeoutDuration ( int  val)

Sets a timeout interval, afterwhich the call is considered to have failed. If no timeout is set, then a default value of 10 seconds is used.

Parameters
valtimeout in milliseconds
bool GCF::IpcCall::waitForDone ( )

Blocks until the done() signal is emitted or timeout

Returns
true if the call was successful, false otherwise.
Note
The call will not freeze any UI while waiting
void GCF::IpcCall::setAutoDelete ( bool  val)

Configures the call enable/disable self-deletion after emitting done().

Parameters
valif true, the call will delete itself after emiting done()
Note
if the isDone() returns true, then the function is a no-op.
bool GCF::IpcCall::isAutoDelete ( ) const
Returns
true if the call would delete itself after emitting done()
void GCF::IpcCall::done ( bool  success)
virtualsignal

This signal is emitted after the call is done. The success parameter is true if the call was successfuly invoked and encountered no error.