Carubbi.Communication
2.0.0
See the version list below for details.
dotnet add package Carubbi.Communication --version 2.0.0
NuGet\Install-Package Carubbi.Communication -Version 2.0.0
<PackageReference Include="Carubbi.Communication" Version="2.0.0" />
<PackageVersion Include="Carubbi.Communication" Version="2.0.0" />
<PackageReference Include="Carubbi.Communication" />
paket add Carubbi.Communication --version 2.0.0
#r "nuget: Carubbi.Communication, 2.0.0"
#:package Carubbi.Communication@2.0.0
#addin nuget:?package=Carubbi.Communication&version=2.0.0
#tool nuget:?package=Carubbi.Communication&version=2.0.0
Carubbi.Communication
Implementation of named pipes stream to abstract the complexity. Allows you to use inter-process communication in a simple way.
Projects
| Project | Package |
|---|---|
Carubbi.Communication |
Carubbi.Communication |
Target framework: net10.0 (Windows). Requires .NET 10 SDK.
Usage
Server
Create a service class that inherits from Server<TRequestMessage, TResponseMessage> and implements ProcessRequest and BeforeStart:
using Carubbi.Communication.NamedPipe;
public class EchoService : Server<string, string>
{
public EchoService() : base(nameof(EchoService))
{
}
protected override string ProcessRequest(string requestMessage)
{
Console.WriteLine($"Message received: {requestMessage}");
return $"Message sent: {requestMessage}";
}
protected override void BeforeStart()
{
Console.WriteLine("Server starting...");
}
}
Start the service in your server app:
var service = new EchoService();
service.Start();
Client
Implement an IObserver<TResponseMessage> to receive the responses:
public class EchoServiceCallback : IObserver<string>
{
public void OnNext(string value) => Console.WriteLine(value);
public void OnError(Exception error) => Console.WriteLine(error.Message);
public void OnCompleted() => Console.WriteLine("Request Completed");
}
Send requests from your client app:
using Carubbi.Communication.NamedPipe;
using (var client = new Client<string, string>("EchoService"))
{
client.BeforeConnect += (sender, eventArgs) => Console.WriteLine("Connecting...");
client.AfterEnd += (sender, eventArgs) => Console.WriteLine("Disconnected.");
client.Subscribe(new EchoServiceCallback());
client.Connect();
Console.WriteLine("Type your message:");
var message = Console.ReadLine();
client.SendRequest(new List<string> { message });
}
The pipe names default to {processName}_SERVER_PIPE (server to client) and {processName}_CALLBACK_PIPE (client to server). Both the server and the client must use the same processName, or pass explicit serverPipeName/callbackPipeName values.
Samples
Run the server and the client samples to see a fully working round-trip:
dotnet run --project samples/Carubbi.Communications.ServerSample -c Release
dotnet run --project samples/Carubbi.Communication.ClientSample -c Release
Building and testing locally
Prerequisites: .NET SDK 10.
dotnet build Carubbi.Communication.slnx -c Release
dotnet run --project tests/Carubbi.Communication.Tests/Carubbi.Communication.Tests.csproj -c Release
Releasing
Pushing a tag v* (for example v2.0.0) triggers the publish workflow, which builds in Release mode, packs the library and publishes it to nuget.org using GitHub Actions trusted publishing.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- Carubbi.Utils (>= 2.0.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.