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);
        }
Beispiel #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);
        }
Beispiel #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);
        }
        public object Handle(WampRpcCall rpcCall)
        {
            Task <object> task = HandleAsync(rpcCall);

            try
            {
                return(task.Result);
            }
            catch (AggregateException ex)
            {
                throw ex.InnerException;
            }
        }
            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);
            }
        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());
        }
            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);
            }