@@ -334,19 +334,30 @@ await SendInvocationError(hubMethodInvocationMessage.InvocationId, connection,
334334 else
335335 {
336336 // Invoke or Send
337- async Task ExecuteInvocation ( )
337+ static async Task ExecuteInvocation ( DefaultHubDispatcher < THub > dispatcher ,
338+ ObjectMethodExecutor methodExecutor ,
339+ THub hub ,
340+ object ? [ ] arguments ,
341+ IServiceScope scope ,
342+ IHubActivator < THub > hubActivator ,
343+ HubConnectionContext connection ,
344+ HubMethodInvocationMessage hubMethodInvocationMessage ,
345+ bool isStreamCall )
338346 {
347+ var logger = dispatcher . _logger ;
348+ var enableDetailedErrors = dispatcher . _enableDetailedErrors ;
349+
339350 object ? result ;
340351 try
341352 {
342- result = await ExecuteHubMethod ( methodExecutor , hub , arguments , connection , scope . ServiceProvider ) ;
343- Log . SendingResult ( _logger , hubMethodInvocationMessage . InvocationId , methodExecutor ) ;
353+ result = await dispatcher . ExecuteHubMethod ( methodExecutor , hub , arguments , connection , scope . ServiceProvider ) ;
354+ Log . SendingResult ( logger , hubMethodInvocationMessage . InvocationId , methodExecutor ) ;
344355 }
345356 catch ( Exception ex )
346357 {
347- Log . FailedInvokingHubMethod ( _logger , hubMethodInvocationMessage . Target , ex ) ;
348- await SendInvocationError ( hubMethodInvocationMessage . InvocationId , connection ,
349- ErrorMessageHelper . BuildErrorMessage ( $ "An unexpected error occurred invoking '{ hubMethodInvocationMessage . Target } ' on the server.", ex , _enableDetailedErrors ) ) ;
358+ Log . FailedInvokingHubMethod ( logger , hubMethodInvocationMessage . Target , ex ) ;
359+ await dispatcher . SendInvocationError ( hubMethodInvocationMessage . InvocationId , connection ,
360+ ErrorMessageHelper . BuildErrorMessage ( $ "An unexpected error occurred invoking '{ hubMethodInvocationMessage . Target } ' on the server.", ex , enableDetailedErrors ) ) ;
350361 return ;
351362 }
352363 finally
@@ -355,7 +366,7 @@ await SendInvocationError(hubMethodInvocationMessage.InvocationId, connection,
355366 // And normal invocations handle cleanup below in the finally
356367 if ( isStreamCall )
357368 {
358- await CleanupInvocation ( connection , hubMethodInvocationMessage , hubActivator , hub , scope ) ;
369+ await dispatcher . CleanupInvocation ( connection , hubMethodInvocationMessage , hubActivator , hub , scope ) ;
359370 }
360371 }
361372
@@ -366,7 +377,8 @@ await SendInvocationError(hubMethodInvocationMessage.InvocationId, connection,
366377 await connection . WriteAsync ( CompletionMessage . WithResult ( hubMethodInvocationMessage . InvocationId , result ) ) ;
367378 }
368379 }
369- invocation = ExecuteInvocation ( ) ;
380+
381+ invocation = ExecuteInvocation ( this , methodExecutor , hub , arguments , scope , hubActivator , connection , hubMethodInvocationMessage , isStreamCall ) ;
370382 }
371383
372384 if ( isStreamCall || isStreamResponse )
0 commit comments