示例#1
0
        public void Result <TMessage>(IWampFormatter <TMessage> formatter, YieldOptions details, TMessage[] arguments)
        {
            ResultDetails resultDetails = GetResultDetails(details);

            this.Result(formatter, resultDetails, arguments);
            UnregisterConnectionClosedIfNeeded(details);
        }
示例#2
0
        private WampRpcInvocation GetInvocation(long requestId, YieldOptions options)
        {
            // This considers the options, since yield can also
            // return a call progress.
            WampRpcInvocation invocation;

            if (mRequestIdToInvocation.TryGetValue(requestId, out invocation))
            {
                bool progressiveResult = options.Progress == true;

                if (!progressiveResult)
                {
                    UnregisterInvocation(invocation);
                    return(invocation);
                }

                bool requestedProgress = invocation.Options.ReceiveProgress == true;

                if (progressiveResult && requestedProgress)
                {
                    return(invocation);
                }
            }

            return(null);
        }
示例#3
0
        public void Result <TMessage>(IWampFormatter <TMessage> formatter, YieldOptions details, TMessage[] arguments,
                                      IDictionary <string, TMessage> argumentsKeywords)
        {
            ResultDetails resultDetails = GetResultDetails(details);

            this.Result(formatter, resultDetails, arguments, argumentsKeywords);
        }
示例#4
0
        private static void InnerInvoke <T>(Func <IRequestContext, IMessage, Task <TResponse> > serviceMethod,
                                            IWampRawRpcOperationRouterCallback caller,
                                            IWampFormatter <T> formatter,
                                            T[] arguments)
        {
            var dummyDetails = new YieldOptions();

            try
            {
                var x = formatter.Deserialize <MessageDto>(arguments[0]);

                var message = new Message
                {
                    ReplyTo = new WampTransientDestination(x.ReplyTo),
                    Payload = Encoding.UTF8.GetBytes(x.Payload.ToString()) // TODO need to stop this from deserializing
                };

                var userSession = new UserSession
                {
                    Username = x.Username
                };

                var userContext = new RequestContext(message, userSession);

                var response = serviceMethod(userContext, message).Result;


                caller.Result(WampObjectFormatter.Value, dummyDetails, new object[] { response });
            }
            catch (Exception e)
            {
                Log.Error(e);
                caller.Error(WampObjectFormatter.Value, dummyDetails, e.Message);
            }
        }
示例#5
0
        protected void CallResult(IWampRawRpcOperationRouterCallback caller, object result, IDictionary <string, object> outputs)
        {
            YieldOptions options = new YieldOptions();

            object[] resultArguments = mEmptyResult;

            if (this.HasResult)
            {
                if (this.CollectionResultTreatment == CollectionResultTreatment.Multivalued)
                {
                    resultArguments = GetFlattenResult((dynamic)result);
                }
                else
                {
                    resultArguments = new object[] { result };
                }
            }

            if (outputs != null)
            {
                caller.Result(ObjectFormatter, options, resultArguments, outputs);
            }
            else if (!this.HasResult)
            {
                caller.Result(ObjectFormatter, options);
            }
            else
            {
                caller.Result(ObjectFormatter, options, resultArguments);
            }
        }
示例#6
0
 private void UnregisterConnectionClosedIfNeeded(YieldOptions details)
 {
     if (details.Progress != true)
     {
         mMonitor.ConnectionClosed -= OnConnectionClosed;
     }
 }
        private void InnerInvoke <T>(Func <IRequestContext, IMessage, Task> serviceMethod,
                                     IWampRawRpcOperationRouterCallback caller,
                                     IWampFormatter <T> formatter,
                                     T[] arguments)
        {
            var dummyDetails = new YieldOptions();

            try
            {
                Task.Run(async() =>
                {
                    try
                    {
                        var guid = Guid.NewGuid();

                        Log.Debug($"[{guid}] RPC operation inner invoke");

                        var x = formatter.Deserialize <MessageDto>(arguments[0]);

                        var payload = x.Payload.ToString();

                        var message = new Message
                        {
                            ReplyTo = new WampTransientDestination(x.ReplyTo),
                            Payload = Encoding.UTF8.GetBytes(payload)
                        };

                        var userSession = new UserSession
                        {
                            Username = x.Username
                        };

                        var userContext = new RequestContext(message, userSession);

                        Log.Debug(
                            $"[{guid}] Calling service method from Username: {userSession.Username}, ReplyTo: {message.ReplyTo}, Payload: {payload}");

                        await serviceMethod(userContext, message);

                        Log.Debug($"[{guid}] Service method called with no exceptions");
                    }
                    catch (Exception e1)
                    {
                        Log.Error(e1, "Error processing RPC operation");
                    }
                });

                caller.Result(WampObjectFormatter.Value, dummyDetails);
            }
            catch (Exception e2)
            {
                Log.Error(e2, "Error processing RPC operation");
                caller.Error(WampObjectFormatter.Value, dummyDetails, e2.Message);
            }
        }
示例#8
0
 protected void CallResult(IWampRawRpcOperationRouterCallback caller, YieldOptions options, object[] arguments, IDictionary <string, object> argumentKeywords)
 {
     if (argumentKeywords != null)
     {
         caller.Result(ObjectFormatter, options, arguments, argumentKeywords);
     }
     else if (!this.HasResult)
     {
         caller.Result(ObjectFormatter, options);
     }
     else
     {
         caller.Result(ObjectFormatter, options, arguments);
     }
 }
示例#9
0
        private void ResultArrived(IWampCallee callee, long requestId, YieldOptions options, Action <WampRpcInvocation> action)
        {
            WampRpcInvocation invocation = GetInvocation(requestId, options);

            if (invocation != null)
            {
                if (invocation.Operation.Callee == callee)
                {
                    action(invocation);
                }
                else
                {
                    callee.InvocationError(requestId, mEmptyDetails, WampErrors.NotAuthorized);
                }
            }
        }
示例#10
0
 public void Yield(IWampCallee callee, long requestId, YieldOptions options, TMessage[] arguments, IDictionary <string, TMessage> argumentsKeywords)
 {
     ResultArrived(callee, requestId, options,
                   invocation =>
                   invocation.Callback.Result(mFormatter, options, arguments, argumentsKeywords));
 }
示例#11
0
 public void Yield(IWampCallee callee, long requestId, YieldOptions options)
 {
     ResultArrived(callee, requestId, options,
                   invocation =>
                   invocation.Callback.Result(mFormatter, options));
 }
示例#12
0
 public void Result <TResult>(IWampFormatter <TResult> formatter, YieldOptions options, TResult[] arguments, IDictionary <string, TResult> argumentsKeywords)
 {
     mProxy.Yield(RequestId, options, arguments.Cast <object>().ToArray(), argumentsKeywords.ToDictionary(x => x.Key, x => (object)x.Value));
 }
 public void Yield(long requestId, YieldOptions options)
 {
     Send(mYield2, requestId, options);
 }
示例#14
0
 public void Yield(IWampCallee callee, long requestId, YieldOptions options, TMessage[] arguments)
 {
     mHandler.Yield(callee, requestId, options, arguments);
 }
 public void Yield(long requestId, YieldOptions options, object[] arguments)
 {
     Send(mYield3, requestId, options, arguments);
 }
示例#16
0
 private ResultDetails GetResultDetails(YieldOptions details)
 {
     return(new ResultDetails {
         Progress = details.Progress
     });
 }
示例#17
0
 public void Yield(IWampCallee callee, long requestId, YieldOptions options, TMessage[] arguments, IDictionary <string, TMessage> argumentsKeywords)
 {
     throw new System.NotImplementedException();
 }
 public void Yield(long requestId, YieldOptions options, object[] arguments, IDictionary <string, object> argumentsKeywords)
 {
     Send(mYield4, requestId, options, arguments, argumentsKeywords);
 }
示例#19
0
 public WampMessage <object> Yield(long requestId, YieldOptions options, object[] arguments)
 {
     return(mSerializer.SerializeRequest(mYield3, new object[] { requestId, options, arguments }));
 }
示例#20
0
 public WampMessage <object> Yield(long requestId, YieldOptions options, object[] arguments, IDictionary <string, object> argumentsKeywords)
 {
     return(mSerializer.SerializeRequest(mYield4, new object[] { requestId, options, arguments, argumentsKeywords }));
 }
示例#21
0
 public void Yield(IWampCallee callee, long requestId, YieldOptions options, TMessage[] arguments)
 {
     throw new System.NotImplementedException();
 }
 public void Yield(IWampCallee callee, long requestId, YieldOptions options)
 {
     throw new NotImplementedException();
 }
示例#23
0
        protected void CallResult(IWampRawRpcOperationRouterCallback caller, object result, IDictionary <string, object> outputs, YieldOptions yieldOptions = null)
        {
            yieldOptions = yieldOptions ?? new YieldOptions();
            object[] resultArguments = GetResultArguments(result);

            IDictionary <string, object> argumentKeywords =
                GetResultArgumentKeywords(result, outputs);

            CallResult(caller,
                       yieldOptions,
                       resultArguments,
                       argumentKeywords);
        }
 public void Result <TMessage>(IWampFormatter <TMessage> formatter, YieldOptions details, TMessage[] arguments)
 {
     caller.Result(formatter, new ResultDetails(), arguments);
 }
示例#25
0
        public void Result <TMessage>(IWampFormatter <TMessage> formatter, YieldOptions details, TMessage[] arguments)
        {
            ResultDetails resultDetails = GetResultDetails(details);

            this.Result(formatter, resultDetails, arguments);
        }
 public void Result <TMessage>(IWampFormatter <TMessage> formatter, YieldOptions details, TMessage[] arguments, IDictionary <string, TMessage> argumentsKeywords) => throw new NotImplementedException();
示例#27
0
 public void Yield(IWampCallee callee, long requestId, YieldOptions options)
 {
     mHandler.Yield(callee, requestId, options);
 }
示例#28
0
 public void Result <TResult>(IWampFormatter <TResult> formatter, YieldOptions options)
 {
     mProxy.Yield(RequestId, options);
 }
示例#29
0
 public void Yield(IWampCallee callee, long requestId, YieldOptions options, TMessage[] arguments, IDictionary <string, TMessage> argumentsKeywords)
 {
     mHandler.Yield(callee, requestId, options, arguments, argumentsKeywords);
 }
示例#30
0
 public void Result <TResult>(IWampFormatter <TResult> formatter, YieldOptions options, TResult[] arguments)
 {
     mProxy.Yield(RequestId, options, arguments.Cast <object>().ToArray());
 }