Ejemplo n.º 1
0
        byte[] callRemote(string funcName, params object[] args)
        {
            RPCFuncCall c = new RPCFuncCall
            {
                FuncName = funcName,
                Args     = Array.ConvertAll(args,
                                            a => new RPCFuncArgVal {
                    ArgValue = byteConverter.ToBytes(a)
                })
            };

            Trace.TraceInformation(string.Format("Sending calling function {0}... ", funcName));

            RPCFuncReturnVal r;

            lock (commLock)
            {
                messenger.SendMessage <RPCFuncCall>(c);
                var np = stream as NamedPipeClientStream;
                if (np != null)
                {
                    np.WaitForPipeDrain();
                }
                r = messenger.ReceiveMessage <RPCFuncReturnVal>();
            }
            if (r.Status == RPCStatus.ReturnOK)
            {
                return(r.RetValue);
            }
            else if (r.Status == RPCStatus.FuncThrewException)
            {
                throw new RpcRemoteException(r.ErrorMsg);
            }
            else if (r.Status == RPCStatus.RPCError)
            {
                throw new CommunicationException(r.ErrorMsg);
            }
            else
            {
                throw new CommunicationException("RPC server returned an invalid status response: " + r.Status);
            }
        }
Ejemplo n.º 2
0
 RPCFuncReturnVal DoMethodCall(RPCFuncCall call)
 {
     return(RpcProcessor.DoMethodCall <TIface>(call,
                                               implementation, byteConverter, customSerializer));
 }