internal virtual PendingCall Call(string serviceName, string methodName, RpcMessage.Parameter[] parameters,
                                          AsyncCallback callback, object state)
        {
            var message = new RpcMessage();

            message.CallMessage               = new RpcMessage.Call();
            message.CallMessage.Service       = serviceName;
            message.CallMessage.Method        = methodName;
            message.CallMessage.ExpectsResult = true;
            if (parameters != null)
            {
                foreach (var param in parameters)
                {
                    message.CallMessage.Parameters.Add(param);
                }
            }

            PendingCall pendingCall;

            lock (pendingCalls)
            {
                int id = GetFreeId();
                message.Id  = id;
                pendingCall = new PendingCall(id, serviceName, methodName, callback, state);
                pendingCalls.Add(id, pendingCall);
            }

            //channel send is thread-safe already
            controller.Send(message);

            return(pendingCall);
        }
        internal virtual void ReceiveResult(RpcMessage message)
        {
            PendingCall pendingCall = pendingCalls[message.Id];

            pendingCalls.Remove(message.Id);
            pendingCall.ReceiveResult(message.ResultMessage);
        }
Ejemplo n.º 3
0
        protected RpcMessage.Parameter EndAsyncCallHelper(string methodName, IAsyncResult asyncResult)
        {
            PendingCall pendingCall = (PendingCall)asyncResult;

            pendingCall.AsyncWaitHandle.WaitOne();
            pendingCall.AsyncWaitHandle.Close();

            if (pendingCall.IsFailed)
            {
                throw new InvalidRpcCallException(serviceName, methodName,
                                                  String.Format("Server failed to process call, returned error message: \"{0}\".",
                                                                pendingCall.ServerErrorMessage));
            }

            return(pendingCall.Result);
        }
Ejemplo n.º 4
0
 public DynamicCallResult(PendingCall pendingCall)
 {
     this.pendingCall = pendingCall;
 }
Ejemplo n.º 5
0
 public DynamicCallResult(PendingCall pendingCall)
 {
     this.pendingCall = pendingCall;
 }