-
Notifications
You must be signed in to change notification settings - Fork 152
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Dynamic codegen of individual delegates to invoke RPC from client #673
Comments
I suppose we could technically add a method to That said, we already have robust support for convenient client proxies via our code generator that implements whole interfaces. Can you use that instead of doing it on a per-delegate basis? |
@AArnott My English is not very good. and I don't quite understand what you mean |
In StreamJsonRpc this would look like: interface IMyRpcInterface
{
Task<List<Order>> ListOrders(int employee, string employeeid);
Task<List<Employee> ListEmployees();
Task<List<Customer> ListCustomers();
} On the server you could implement that interface. IMyRpcInterface proxy = JsonRpc.Attach<IMyRpcInterface>(stream);
List<Employee> await proxy.ListEmployees(); |
@AArnott
Currently, vs-streamjsonrpc does not support "delegate event" |
Thanks for helping me understand you're interested in reverse-direction RPC. Did you know that the RPC interface can include events? interface IMyRpcInterface
{
event EventHandler<ChangeDetails> EmployeesChanged;
Task<List<Order>> ListOrders(int employee, string employeeid);
Task<List<Employee> ListEmployees();
Task<List<Customer> ListCustomers();
} This can make it particularly convenient for a client/server paradigm designed interface to let the server call back to the client for notifications. |
yes ,i find a doc: |
I'm sorry, I don't understand your question. Every event in C# is based on delegates. On the server and client you implement and add handlers to events as if it were ordinary C# code, and StreamJsonRpc makes them just work. If you're unfamiliar with events in C#, please learn that first then come back here if it works in the local case but not over RPC. |
Contract:
server:
client:
expect:When the server calls the
DataChange
delegate, the client will execute: Console.WriteLine(..........);The text was updated successfully, but these errors were encountered: