public void HandleMesage(RpcRequest msg) { if (msg.UtcExpiryTime != null && msg.UtcExpiryTime < DateTime.UtcNow) { Global.DefaultWatcher.WarnFormat("Msg {0}.{1} from {2} has been expired", msg.DeclaringType, msg.MethodName, msg.ResponseAddress); return; } var response = new RpcResponse { RequestId = msg.Id, }; try { var methodInfo = InternalDependencies.MethodMatcher.Match <T>(msg); if (methodInfo == null) { throw new Exception(string.Format("Could not find a match member of type {0} for method {1} of {2}", msg.MemberType.ToString(), msg.MethodName, msg.DeclaringType)); } var parameters = methodInfo.GetParameters(); //NOTE: Fix param type due to int32/int64 serialization problem foreach (var param in parameters) { if (param.ParameterType.IsPrimitive) { msg.Params[param.Name] = msg.Params[param.Name].ConvertToCorrectTypeValue(param.ParameterType); } } object[] parameterValues = msg.Params.Values.ToArray(); response.ReturnValue = methodInfo.Invoke(_realInstance, parameterValues); var keys = msg.Params.Keys.ToArray(); for (int i = 0; i < msg.Params.Count; i++) { msg.Params[keys[i]] = parameterValues[i]; } response.ChangedParams = msg.Params; } catch (Exception ex) { response.Exception = ex; } if (!string.IsNullOrEmpty(msg.ResponseAddress)) { _tunnel.Publish(response, msg.ResponseAddress); } }
public virtual void SendAsync(RpcRequest request) { request.ResponseAddress = null; // Don't need response _tunnel.Publish(request, _routeFinder.RequestQueue); }