Lightweight .NET Standard 2.0 library for method calls over named pipes for IPC. Supports two-way communication with callbacks.
$ dotnet add package PipeMethodCallsLightweight .NET Standard 2.0 library to use method calls over named and anonymous pipes for IPC. Supports two-way communication with callbacks.
var pipeServer = new PipeServer<IAdder>(
new NetJsonPipeSerializer(),
"mypipe",
() => new Adder());
await pipeServer.WaitForConnectionAsync();
var pipeClient = new PipeClient<IAdder>(new NetJsonPipeSerializer(), "mypipe");
await pipeClient.ConnectAsync();
int result = await pipeClient.InvokeAsync(adder => adder.AddNumbers(1, 3));
var pipeServer = new PipeServerWithCallback<IConcatenator, IAdder>(
new NetJsonPipeSerializer(),
"mypipe",
() => new Adder());
await pipeServer.WaitForConnectionAsync();
string concatResult = await pipeServer.InvokeAsync(c => c.Concatenate("a", "b"));
var pipeClient = new PipeClientWithCallback<IAdder, IConcatenator>(
new NetJsonPipeSerializer(),
"mypipe",
() => new Concatenator());
await pipeClient.ConnectAsync();
int result = await pipeClient.InvokeAsync(a => a.AddNumbers(4, 7));
This library uses named pipes to invoke method calls on a remote endpoint. The method arguments are serialized to binary and sent over the pipe.
PipeMethodCalls supports customizable serialization logic through IPipeSerializer. You've got two options:
new NetJsonPipeSerializer() from the PipeMethodCalls.NetJson package. That uses the System.Text.Json serializer that's built into .NET.new MessagePackPipeSerializer() from the PipeMethodCalls.MessagePack package. That uses the MessagePack-CSharp serializer, which has excellent performance.IPipeSerializer. Refer to the NetJsonPipeSerializer code for an example of how to do this.Open an issue or pull request if you'd like to see more built-in serializers.