virtual public void Invoke(ISender target, Channel q, string method,
params object[] args)
{
//build state for the RPC call
RpcRequestState rs = new RpcRequestState();
rs.Results = q;
rs.RpcTarget = target;
object[] rpc_call = new object[2];
rpc_call[0] = method;
if( args != null ) {
rpc_call[1] = args;
}
else {
//There are no args, which we represent as a zero length list
rpc_call[1] = new object[0];
}
AdrCopyable req_copy = new AdrCopyable(rpc_call);
#if RPC_DEBUG
Console.Error.WriteLine("[RpcClient: {0}] Invoking method: {1} on target: {2}",
_rrman.Info, method, target);
#endif
ICopyable rrpayload = new CopyList( PType.Protocol.Rpc, req_copy );
int reqid = _rrman.SendRequest(target, ReqrepManager.ReqrepType.Request,
rrpayload, this, rs);
//Make sure we stop this request when the queue is closed.
if( q != null ) {
try {
q.CloseEvent += delegate(object qu, EventArgs eargs) {
_rrman.StopRequest(reqid, this);
};
}
catch {
if(q.Closed) {
_rrman.StopRequest(reqid, this);
}
else {
throw;
}
}
}
}