You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm not sure if this is a bug or an enhancement request. It depends on your view of what an event should be.
Use Case:
Using dynamic proxies with events.
Use the RemoteRpcTarget functionality and add "two clients".
Interface "attached" to exposes an event.
Nomenclature in the diagram above might not be quite right, but hopefully you can follow. The server JsonRpc added two remote targets. Each of these objects connects to a client. Client #1 publishes a MyAPI object as a local target. Server, Client #2 or Client #3 could retrieve the interface by attaching to the IMyAPI interface.
The IMyAPI interface includes an event that the server or clients can register for.
Problem
The issue here is that three different JsonRpc objects have retrieved dynamic proxies to interact with the MyAPI target. Calling methods from the interface work fine, but events don't work as I expected them. Let's say all three registered for the event. Well, the server JsonRpc will find the event method in a local target and invoke it. Then it is done. The event will not be called in the two clients.
If the server does not register for this event, then DispatchIncomingRequestAsync will look through the remote targets and forward the message. Great, except that it stops after the first one. So only Client #2 will get the event, even if Client #3 is the only one to register for the event, it will never get to it.
Additional Bug
This might be an actual bug. When DispatchIncomingRequestAsync forwards a request when no response is expected, such as a notification. remoteResponse = await remoteTarget.InvokeCoreAsync(request, null, token).ConfigureAwait(false);
That line retursn a null remoteResponse which causes a JsonRpcError to be returned rather than a "null response".
Our "Fix"
With the caveat that this might not be what the design called for in terms of notifications, we changed our DispatchIncomingRequestAsync so that it forwards notifications to a local target as well as to all remote targets. We also changed it to return a single null result when calling all local and remote targets which seems to be what a notification should return.
return new JsonRpcResult
{
RequestId = request.RequestId,
Result = null,
};
So in the use case above, everyone would have received the event and Client #1, which raised the notification, receives its single null result. In my mind, that behaves in a more C#ish way.
The text was updated successfully, but these errors were encountered:
I'm not sure if this is a bug or an enhancement request. It depends on your view of what an event should be.
Use Case:
Nomenclature in the diagram above might not be quite right, but hopefully you can follow. The server JsonRpc added two remote targets. Each of these objects connects to a client. Client #1 publishes a MyAPI object as a local target. Server, Client #2 or Client #3 could retrieve the interface by attaching to the IMyAPI interface.
The IMyAPI interface includes an event that the server or clients can register for.
Problem
The issue here is that three different JsonRpc objects have retrieved dynamic proxies to interact with the MyAPI target. Calling methods from the interface work fine, but events don't work as I expected them. Let's say all three registered for the event. Well, the server JsonRpc will find the event method in a local target and invoke it. Then it is done. The event will not be called in the two clients.
If the server does not register for this event, then DispatchIncomingRequestAsync will look through the remote targets and forward the message. Great, except that it stops after the first one. So only Client #2 will get the event, even if Client #3 is the only one to register for the event, it will never get to it.
Additional Bug
This might be an actual bug. When DispatchIncomingRequestAsync forwards a request when no response is expected, such as a notification.
remoteResponse = await remoteTarget.InvokeCoreAsync(request, null, token).ConfigureAwait(false);
That line retursn a null remoteResponse which causes a JsonRpcError to be returned rather than a "null response".
Our "Fix"
With the caveat that this might not be what the design called for in terms of notifications, we changed our DispatchIncomingRequestAsync so that it forwards notifications to a local target as well as to all remote targets. We also changed it to return a single null result when calling all local and remote targets which seems to be what a notification should return.
So in the use case above, everyone would have received the event and Client #1, which raised the notification, receives its single null result. In my mind, that behaves in a more C#ish way.
The text was updated successfully, but these errors were encountered: