@@ -54,8 +54,8 @@ public class InputHandler : IInputHandler, IDisposable
54
54
private readonly CompositeDisposable _disposable ;
55
55
private readonly AsyncSubject < Unit > _inputActive ;
56
56
57
- private readonly ConcurrentDictionary < object , ( CancellationTokenSource cancellationTokenSource , IHandlerDescriptor descriptor ) > _requests =
58
- new ConcurrentDictionary < object , ( CancellationTokenSource cancellationTokenSource , IHandlerDescriptor descriptor ) > ( ) ;
57
+ private readonly ConcurrentDictionary < object , ( CancellationTokenSource cancellationTokenSource , IRequestDescriptor < IHandlerDescriptor > descriptor ) > _requests =
58
+ new ConcurrentDictionary < object , ( CancellationTokenSource cancellationTokenSource , IRequestDescriptor < IHandlerDescriptor > descriptor ) > ( ) ;
59
59
60
60
private readonly Subject < IObservable < Unit > > _inputQueue ;
61
61
@@ -410,15 +410,15 @@ private void HandleRequest(in ReadOnlySequence<byte> request)
410
410
if ( item . IsRequest )
411
411
{
412
412
// _logger.LogDebug("Handling Request {Method} {ResponseId}", item.Request.Method, item.Request.Id);
413
- var descriptor = _requestRouter . GetDescriptor ( item . Request ) ;
414
- if ( descriptor is null )
413
+ var descriptor = _requestRouter . GetDescriptors ( item . Request ) ;
414
+ if ( descriptor . Default is null )
415
415
{
416
416
_logger . LogDebug ( "Request handler was not found (or not setup) {Method} {ResponseId}" , item . Request . Method , item . Request . Id ) ;
417
417
_outputHandler . Send ( new MethodNotFound ( item . Request . Id , item . Request . Method ) ) ;
418
418
return ;
419
419
}
420
420
421
- var type = _requestProcessIdentifier . Identify ( descriptor ) ;
421
+ var type = _requestProcessIdentifier . Identify ( descriptor . Default ) ;
422
422
_scheduler . Add ( type , $ "{ item . Request . Method } :{ item . Request . Id } ", RouteRequest ( descriptor , item . Request ) ) ;
423
423
}
424
424
@@ -445,16 +445,16 @@ private void HandleRequest(in ReadOnlySequence<byte> request)
445
445
}
446
446
447
447
// _logger.LogDebug("Handling Request {Method}", item.Notification.Method);
448
- var descriptor = _requestRouter . GetDescriptor ( item . Notification ) ;
449
- if ( descriptor is null )
448
+ var descriptor = _requestRouter . GetDescriptors ( item . Notification ) ;
449
+ if ( descriptor . Default is null )
450
450
{
451
451
_logger . LogDebug ( "Notification handler was not found (or not setup) {Method}" , item . Notification . Method ) ;
452
452
// TODO: Figure out a good way to send this feedback back.
453
453
// _outputHandler.Send(new RpcError(null, new ErrorMessage(-32601, $"Method not found - {item.Notification.Method}")));
454
454
return ;
455
455
}
456
456
457
- var type = _requestProcessIdentifier . Identify ( descriptor ) ;
457
+ var type = _requestProcessIdentifier . Identify ( descriptor . Default ) ;
458
458
_scheduler . Add ( type , item . Notification . Method , RouteNotification ( descriptor , item . Notification ) ) ;
459
459
}
460
460
@@ -465,11 +465,11 @@ private void HandleRequest(in ReadOnlySequence<byte> request)
465
465
}
466
466
}
467
467
468
- private SchedulerDelegate RouteRequest ( IHandlerDescriptor descriptor , Request request )
468
+ private SchedulerDelegate RouteRequest ( IRequestDescriptor < IHandlerDescriptor > descriptors , Request request )
469
469
{
470
470
// start request, create cts, etc
471
471
var cts = new CancellationTokenSource ( ) ;
472
- _requests . TryAdd ( request . Id , ( cts , descriptor ) ) ;
472
+ _requests . TryAdd ( request . Id , ( cts , descriptors ) ) ;
473
473
474
474
return ( contentModifiedToken , scheduler ) => Observable . Create < ErrorResponse > ( observer => {
475
475
// ITS A RACE!
@@ -485,7 +485,7 @@ private SchedulerDelegate RouteRequest(IHandlerDescriptor descriptor, Request re
485
485
// ObservableToToken(contentModifiedToken).Register(cts.Cancel);
486
486
try
487
487
{
488
- return await _requestRouter . RouteRequest ( descriptor , request , cts . Token ) ;
488
+ return await _requestRouter . RouteRequest ( descriptors , request , cts . Token ) ;
489
489
}
490
490
catch ( OperationCanceledException )
491
491
{
@@ -521,7 +521,7 @@ private SchedulerDelegate RouteRequest(IHandlerDescriptor descriptor, Request re
521
521
} ) ;
522
522
}
523
523
524
- private SchedulerDelegate RouteNotification ( IHandlerDescriptor descriptor , Notification notification )
524
+ private SchedulerDelegate RouteNotification ( IRequestDescriptor < IHandlerDescriptor > descriptors , Notification notification )
525
525
{
526
526
return ( contentModifiedToken , scheduler ) =>
527
527
// ITS A RACE!
@@ -536,7 +536,7 @@ private SchedulerDelegate RouteNotification(IHandlerDescriptor descriptor, Notif
536
536
using var timer = _logger . TimeDebug ( "Processing notification {Method}" , notification . Method ) ;
537
537
try
538
538
{
539
- await _requestRouter . RouteNotification ( descriptor , notification , ct ) ;
539
+ await _requestRouter . RouteNotification ( descriptors , notification , ct ) ;
540
540
}
541
541
catch ( OperationCanceledException )
542
542
{
0 commit comments