Skip to content

Xenoage/RpcLib

Repository files navigation

💡 This library was completely rewritten, using WebSocket based communication. The README and wiki pages are not yet up to date!

@@ Just arrived: @@
+ WebSocket base communication
+ Compact communication protocol
- ASP.NET Core dependency
- HTTP Long Polling

Xenoage.RpcLib

A simple .NET Core RPC library for bidirectional, reliable and typesafe communication between an ASP.NET Core server with HTTP/S Web API endpoints and clients behind a firewall.

NuGet version (Xenoage.RpcLib)

Early alpha version - more documentation will follow.

Overview

Overview

Illustration of the infrastructure: 1 server with HTTP(S) endpoints, N clients, direct client-to-server calls, indirect server-to-client calls (long polling)

Usage

After integrating the library in your project as described below, it is very easy to call methods on the remote peer. It feels very natural, just like calling them on the local side! If you are calling from the client to the server or the other way, the code looks the same. A shortened example just to get a feeling:

// Method declarations (excerpt)
interface IRemoteCalculator : IRpcFunctions {
   Task<int> AddNumbers(int n1, int n2);
}

// Caller-side code (excerpt)
IRemoteCalculator calc = ...;
try {
   int sum = await calc.AddNumbers(5, 10); // This method will be executed on the remote peer
   Console.WriteLine("Result should be 15: " + sum);
}
catch (RpcException ex) {
   if (ex.IsRpcProblem)
      Console.WriteLine("Could not reach the remote peer. Try again later.");
   else
      Console.WriteLine("The remote peer threw an exception: " + ex.Message);
}

// Callee-side code (excerpt)
public async Task<int> AddNumbers(int n1, int n2) {
   return n1 + n2;
}

More information

For more information how to integrate the library into your project, use special features like timeouts, automatic retries or compression and get explanations on the included demo projects, please have a look in our wiki. It is also possible to use your JSON serializer and logging framework within the RPC library.

This library is very new and changes will happen frequently. Contributions are welcome.

About

.NET Core bidirectional, reliable and typesafe RPC library for an HTTP/S server and clients behind a firewall

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages