public void Result <TMessage>(IWampFormatter <TMessage> formatter, YieldOptions details, TMessage[] arguments) { ResultDetails resultDetails = GetResultDetails(details); this.Result(formatter, resultDetails, arguments); UnregisterConnectionClosedIfNeeded(details); }
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); }
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); }
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); } }
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); } }
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); } }
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); } }
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); } } }
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)); }
public void Yield(IWampCallee callee, long requestId, YieldOptions options) { ResultArrived(callee, requestId, options, invocation => invocation.Callback.Result(mFormatter, options)); }
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); }
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); }
private ResultDetails GetResultDetails(YieldOptions details) { return(new ResultDetails { Progress = details.Progress }); }
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); }
public WampMessage <object> Yield(long requestId, YieldOptions options, object[] arguments) { return(mSerializer.SerializeRequest(mYield3, new object[] { requestId, options, arguments })); }
public WampMessage <object> Yield(long requestId, YieldOptions options, object[] arguments, IDictionary <string, object> argumentsKeywords) { return(mSerializer.SerializeRequest(mYield4, new object[] { requestId, options, arguments, argumentsKeywords })); }
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(); }
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); }
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();
public void Yield(IWampCallee callee, long requestId, YieldOptions options) { mHandler.Yield(callee, requestId, options); }
public void Result <TResult>(IWampFormatter <TResult> formatter, YieldOptions options) { mProxy.Yield(RequestId, options); }
public void Yield(IWampCallee callee, long requestId, YieldOptions options, TMessage[] arguments, IDictionary <string, TMessage> argumentsKeywords) { mHandler.Yield(callee, requestId, options, arguments, argumentsKeywords); }
public void Result <TResult>(IWampFormatter <TResult> formatter, YieldOptions options, TResult[] arguments) { mProxy.Yield(RequestId, options, arguments.Cast <object>().ToArray()); }