public override void Intercept(IInvocation invocation)
        {
            WampRpcCall wampRpcCall = Serializer.Serialize(invocation.Method, invocation.Arguments);
            object      result      = ClientHandler.Handle(wampRpcCall);

            invocation.ReturnValue = result;
        }
        public override object Invoke(MethodInfo method, object[] arguments)
        {
            WampRpcCall wampRpcCall = Serializer.Serialize(method, arguments);
            object      result      = ClientHandler.Handle(wampRpcCall);

            return(result);
        }
예제 #3
0
        public override void Intercept(IInvocation invocation)
        {
            WampRpcCall call =
                Serializer.Serialize(invocation.Method, invocation.Arguments);

            Task <object> task = ClientHandler.HandleAsync(call);

            Task convertedTask = task.Cast(call.ReturnType);

            invocation.ReturnValue = convertedTask;
        }
        public override object Invoke(MethodInfo method, object[] arguments)
        {
            WampRpcCall call =
                Serializer.Serialize(method, arguments);

            Task <object> task = ClientHandler.HandleAsync(call);

            Task convertedTask = task.Cast(call.ReturnType);

            return(convertedTask);
        }
예제 #5
0
        public WampRpcCall Serialize(MethodInfo method, object[] arguments)
        {
            WampRpcCall result = new WampRpcCall()
            {
                Arguments = arguments,
                ProcUri   = mProcUriMapper.Map(method),
            };

            result.ReturnType =
                TaskExtensions.UnwrapReturnType(method.ReturnType);

            return(result);
        }
예제 #6
0
        public object Handle(WampRpcCall rpcCall)
        {
            Task <object> task = HandleAsync(rpcCall);

            try
            {
                return(task.Result);
            }
            catch (AggregateException ex)
            {
                throw ex.InnerException;
            }
        }
예제 #7
0
            private WampRpcCall CallRpcMethod(Type returnType)
            {
                WampRpcMethodInfo method = new WampRpcMethodInfo(MethodName, returnType);

                WampRpcCall rpcCall = mClient.Serializer.Serialize(method, Arguments);

                if (mTask == null)
                {
                    mTask = mClient.ClientHandler.HandleAsync(rpcCall);
                }

                return(rpcCall);
            }
예제 #8
0
        public Task <object> HandleAsync(WampRpcCall rpcCall)
        {
            rpcCall.CallId = Guid.NewGuid().ToString();
            // TODO: replace this with CallIdGenerator
            WampRpcRequest    wampRpcRequest = new WampRpcRequest();
            ISubject <object> task           = new ReplaySubject <object>(1);

            wampRpcRequest.Request = rpcCall;
            wampRpcRequest.Task    = task;

            mCallIdToSubject[rpcCall.CallId] = wampRpcRequest;

            mServerProxy.Call(null, rpcCall.CallId, rpcCall.ProcUri, rpcCall.Arguments);

            return(task.ToTask());
        }
예제 #9
0
            public override bool TryConvert(ConvertBinder binder, out object result)
            {
                Type returnType = binder.Type;

                WampRpcCall rpcCall = CallRpcMethod(returnType);

                if (!typeof(Task).IsAssignableFrom(returnType))
                {
                    result = mTask.Result;
                }
                else
                {
                    result = mTask.Cast(rpcCall.ReturnType);
                }

                return(true);
            }