vs-streamjsonrpc
vs-streamjsonrpc copied to clipboard
Support for passing delegates as arguments over RPC
@tmat brought up a scenario where they would find it very useful if StreamJsonRpc supported passing delegates as arguments over JSON-RPC.
We already support passing IProgress<T>
(and other exotic types) which effectively provides a callback target that is very unique to a particular RPC call. Passing a raw delegate just makes it that much easier and gives a more native .NET feel.
IProgress is nice as you can report/notify/fire-and-forget whatever T you want. Thou would be nice with some way (IAsyncProgress?) to have a Task Report (T value) that can be awaited. Thou I assume this enhancement will cover that case.
Hi There are any plans to do this?
Nothing has been scheduled.
We would need a clear definition of delegate lifetime. It probably wouldn't last longer than the call that provided the delegate. Otherwise, there's no clear way to know when resources held by the delegate host can be freed (when the delegate receiver has discarded the delegate).
Do you have any plans for this now, passing the delegate as a parameter to JsonRpc to implement a callback. I plan to add the following to my Demo: https://github.com/Tianfei-Wang/StreamJsonRpcTcp/blob/master/JsonRpcClient/Exe1Impl.cs#:~:text=Exe1Proxy.RegisterDelegate(delId%2Chandler)%3B Passing the delegate type to the server through JsonRpc, and then the server notifies the client and sends an event parameter: https://github.com/Tianfei-Wang/StreamJsonRpcTcp/blob/master/JsonRpc_Server/Exe1Obj.cs#:~:text=testEventHandler.DynamicInvoke(args)%3B Or are there any other solutions to achieve similar functions?
We have no plans to add delegate passing support at this point.