MB.TinyRpc 1.11.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package MB.TinyRpc --version 1.11.0                
NuGet\Install-Package MB.TinyRpc -Version 1.11.0                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="MB.TinyRpc" Version="1.11.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add MB.TinyRpc --version 1.11.0                
#r "nuget: MB.TinyRpc, 1.11.0"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install MB.TinyRpc as a Cake Addin
#addin nuget:?package=MB.TinyRpc&version=1.11.0

// Install MB.TinyRpc as a Cake Tool
#tool nuget:?package=MB.TinyRpc&version=1.11.0                

MB.TinyRpc

TinyRpc is a small, fast 1:1 RPC client-server framework that uses source generation to communicate using binary data over pipes.

It sends as little data as necessary, without run-time checks. If the common interface doesn't have events, for example, the machinery to support them isn't generated. Similarly, void returns or parameters don't send anything over the pipe.

It also automatically starts the server when the client is instantiated and it automatically closes the server when the client shuts down (even if it doesn't shut down gracefully). There is no possibility of getting out-of-sync orphaned servers.

Support

Type .NET Windows C++
Server
Client

Common interface definition

The source of any operation is a .Net interface that can contain methods or events. This interface doesn't have to be a single common type as long as the definition matches. For example, in the sample provided it's used in a shared project (thus creating two different types):

internal interface IServer
{
    void Hi();
    void FancyHi(string name, int age);
    int Add(int x, int y);
    byte[] BufferCall(byte[] baseUtf8String, int n);
    (int a, int b, short c, byte[] utf8) GetValueTupleResult(string s);
    (uint a, long b, DateTime dt, double d)[] GetValueTupleArrayResult();

    event Action<double, string> OnData;
}

.NET Server

The pattern for creating a .NET server is as follows:

  1. Reference MB.TinyRpc.
  2. Instantiate the interface to a concrete class that handles the functions as needed.
  3. Create a new partial class and decorate it with [TinyRpcServerClass(typeof(ServerHandler))], where ServerHandler is your concrete class name.
  4. Instantiate the server class above in code. This will create the listener on your thread pool and keep the IsHealthy property up to date.

You can find an example of this here.

.NET Client

The pattern for creating a .NET client is as follows:

  1. Reference MB.TinyRpc.
  2. Create a partial class and decorate it with [TinyRpcClientClass(typeof(IServer))], where IServer is the common interface above.
  3. Instantiate the class and call the provided async functions on it, or fire its events.

You can find an example of this here.

C++ Client

  1. Reference MB.TinyRpc.CppGen.
  2. Add a pre-build event that calls the code generator on the .Net client project to extract information about the interface type and build the C++ header file:
"$(ProjectDir)TinyRpcCppGen\tinyRpc.CppGen.exe" --input-project-path "$(SolutionDir)SampleClient\SampleClient.csproj" --input-class-names "SampleShared.IServer" --output-path "$(ProjectDir)TinyRpcServer.h" --output-class-names "TinyRpcServer"
  1. Include the generated header file and call its functions or fire its events.

You can find an example of this here.

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.13.0 94 9/30/2024
1.12.0 81 9/30/2024
1.11.0 85 9/29/2024
1.10.0 369 3/15/2024
1.9.0 260 11/5/2023
1.8.0 160 11/2/2023
1.7.0 152 10/31/2023
1.6.2 147 10/31/2023
1.6.0 145 10/31/2023
1.5.0 133 10/28/2023
1.4.0 162 10/4/2023
1.3.0 130 10/3/2023
1.2.0 148 10/3/2023
1.1.0 143 10/3/2023
1.0.0 149 10/3/2023