Ejemplo n.º 1
0
        internal static Task <HubMethodResult> IncomingWrapped(IHubIncomingInvokerContext context)
        {
            var tcs = new TaskCompletionSource <HubMethodResult>();

            Incoming(context).ContinueWith((t) =>
            {
                if (t.IsFaulted)
                {
                    tcs.TrySetUnwrappedException(t.Exception);
                }
                else if (t.IsCanceled)
                {
                    tcs.TrySetCanceled();
                }
                else
                {
                    tcs.TrySetResult(HubMethodResult.Result(t.Result));
                }
            });
            return(tcs.Task);
        }
Ejemplo n.º 2
0
        private Task ProcessResponse(StateChangeTracker tracker, HubMethodResult result, HubRequest request, Exception error)
        {
            var hubResult = new HubResponse
            {
                State = tracker.GetChanges(),
                Id    = request.Id,
            };

            if (result != null)
            {
                if (result.IsError)
                {
                    hubResult.Error = result.Value;
                }
                else
                {
                    hubResult.Result = result.Value;
                }
            }
            else if (error != null)
            {
                _counters.ErrorsHubInvocationTotal.Increment();
                _counters.ErrorsHubInvocationPerSec.Increment();
                _counters.ErrorsAllTotal.Increment();
                _counters.ErrorsAllPerSec.Increment();

                if (_enableDetailedErrors)
                {
                    var exception = error.InnerException ?? error;
                    hubResult.StackTrace = _isDebuggingEnabled ? exception.StackTrace : null;
                    hubResult.Error      = exception.Message;
                }
                else
                {
                    hubResult.Error = String.Format(CultureInfo.CurrentCulture, Resources.Error_HubInvocationFailed, request.Hub, request.Method);
                }
            }

            return(Transport.Send(hubResult));
        }
Ejemplo n.º 3
0
 /// <summary>
 /// This method is called after the incoming components of any modules added later to the <see cref="IHubPipeline"/>
 /// and the server-side hub method have completed execution.
 /// </summary>
 /// <param name="result">The return value of the server-side hub method</param>
 /// <param name="context">A description of the server-side hub method invocation.</param>
 /// <returns>The possibly new or updated return value of the server-side hub method</returns>
 protected virtual HubMethodResult OnAfterIncoming(HubMethodResult result, IHubIncomingInvokerContext context)
 {
     return(result);
 }
Ejemplo n.º 4
0
 /// <summary>
 /// This method is called after the incoming components of any modules added later to the <see cref="IHubPipeline"/>
 /// and the server-side hub method have completed execution.
 /// </summary>
 /// <param name="result">The return value of the server-side hub method</param>
 /// <param name="context">A description of the server-side hub method invocation.</param>
 /// <returns>The possibly new or updated return value of the server-side hub method</returns>
 protected virtual HubMethodResult OnAfterIncoming(HubMethodResult result, IHubIncomingInvokerContext context)
 {
     return result;
 }