@@ -56,34 +56,34 @@ public Task RegisterSchemesAsPrivilegedAsync(params CustomScheme[] customSchemes
5656 /// </summary>
5757 /// <param name="scheme">scheme to handle, for example https or my-app. This is the bit before the : in a URL.</param>
5858 /// <param name="handler">Either a <see cref="Response" /> or a <see cref="Task{Response}"/> can be returned.</param>
59- public Task HandleAsync ( string scheme , Func < Request , Response > handler )
59+ public void Handle ( string scheme , Func < Request , Response > handler )
6060 {
6161 if ( string . IsNullOrWhiteSpace ( scheme ) )
6262 throw new ArgumentException ( "Scheme must not be null or empty." , nameof ( scheme ) ) ;
6363
64- return handler switch
65- {
66- null => throw new ArgumentNullException ( nameof ( handler ) ) ,
67- _ => HandleAsync ( scheme , req => Task . FromResult ( handler ( req ) ) )
68- } ;
64+ if ( handler == null )
65+ throw new ArgumentNullException ( nameof ( handler ) ) ;
66+
67+ Handle ( scheme , req => Task . FromResult ( handler ( req ) ) ) ;
6968 }
7069
71- public Task HandleAsync ( string scheme , Func < Request , Task < Response > > handler )
70+ public void Handle ( string scheme , Func < Request , Task < Response > > handler )
7271 {
7372 if ( string . IsNullOrWhiteSpace ( scheme ) )
7473 throw new ArgumentException ( "Scheme must not be null or empty." , nameof ( scheme ) ) ;
7574
7675 if ( handler == null )
7776 throw new ArgumentNullException ( nameof ( handler ) ) ;
7877
78+ var tsc = new TaskCompletionSource ( ) ;
79+
7980 // Tell TS to register protocol.handle for this scheme.
8081 BridgeConnector . Socket . Emit ( "protocol-handle-register" , new
8182 {
8283 scheme
8384 } ) ;
8485
8586 // Listen for incoming requests from TS
86- // Note: If your BridgeConnector has generic On<T>, use that instead of object.
8787 BridgeConnector . Socket . On < Request > ( "protocol-handle-request" , async ( request ) =>
8888 {
8989 try
@@ -133,9 +133,6 @@ public Task HandleAsync(string scheme, Func<Request, Task<Response>> handler)
133133 } ) ;
134134 }
135135 } ) ;
136-
137- // There’s nothing async to wait for here: registration happens on JS side.
138- return Task . CompletedTask ;
139136 }
140137 }
141138
0 commit comments