SoM.Ipc
0.5.2-pre
dotnet add package SoM.Ipc --version 0.5.2-pre
NuGet\Install-Package SoM.Ipc -Version 0.5.2-pre
<PackageReference Include="SoM.Ipc" Version="0.5.2-pre" />
<PackageVersion Include="SoM.Ipc" Version="0.5.2-pre" />
<PackageReference Include="SoM.Ipc" />
paket add SoM.Ipc --version 0.5.2-pre
#r "nuget: SoM.Ipc, 0.5.2-pre"
#:package SoM.Ipc@0.5.2-pre
#addin nuget:?package=SoM.Ipc&version=0.5.2-pre&prerelease
#tool nuget:?package=SoM.Ipc&version=0.5.2-pre&prerelease
SoM.Ipc
An Net API style Ipc abstraction independent of used framework ( WatsonTcp, SignalR, other )
A library that allows quick setup of Ipc ( [ Inter | Remote ]-Process-Communication) between .Net Core/Core or Core/Framework apps with minimal boilerplate. Abstracts IPC in a way that allows trivial changes of underling communication framework ( SignalR, WatsonTcp, RabbitMq, etc) without changes to methods that actually handle the incoming events/requests. . We use it to migrate existing services from Net Framework to .Net with WatsonTcp being a commonly supported step framework along the way. Uploaded to NuGet for convenience of use.
Features:
- Supports Events ( one way send ) ot Requests ( needs a response ) between clients/server ( both ways )
- Follows ASP.Net Api style ( Use attributes to mark a class as an IPC controller and a method as end an endpoint handler )
- Monitors connection with periodic pings and Auto-reconnects
- Serializes dto's to json with short type discriminators
Server usage
Register with Dependency Injection in program.cs:
var builder = Host.CreateApplicationBuilder(args);
…
builder.Services.AddKeyedSoMIpcWatsonTcpService("MyIpc1",
(options) =>
{
options.Uri = "127.0.0.1:50543";
});
…
or use appsettings.json
"MyIpc1": {
"Uri": "10.0.0.100:50543"
},
with
# builder.Services.AddKeyedSoMIpcWatsonTcpService("MyIpc1")
Server
IpcServices _ipc; // DI injected
var srv = _ipc.Get("MyIpc1"); // <- get server instance
…
/* send event to all connected clients */
srv.SendEventAsync( new MyIpc1.DemoIpcA() { Endpoint = "foo.evtA") });
BoilerPlate that IS required
/* server side */
[SoMEndpointController] // <-- mark class as containing endpoint handlers ( speeds up finding handler methods on startup )
class Controller {
…
/* receive a one-way event from the client */
[SoMEndpoint("foo.evtA")] // <- client specified foo.evtA as endpoint for the
public void OnAReceived(DemoIpcA msg, IpcMetadata src)
{
Console.WriteLine($"Got A = {msg.PropA}");
}
…
}
/* Dto objects ( inherited from SoMIpcMessage )
/// <summary>
/// Create a Message Dto ( DataTransferObject) type to send to and from server.
/// Mark it as Dto and serializable by adding SoMIpc attribute with unique string discriminator
/// </summary>
[SoMIpc("nov.A")]
public class DemoIpcA : SoMIpcMessage
{
public string PropA { get; set; }
}
client usage
/* client side call to server */
IpcClient<WatsonTcpClientConnector> _ipc = new IpcClient<FrWatsonTcp>( optionalILogger);
_ipc.Connect(new HubConnectionOptions() {
Server = "127.0.0.1",
Port = 50543,
});
…
/* invoke server method marked as eventhandler for "foo.evtA" , passing it our Dto */
await _ipc.SendEventAsync(new MyIpc1.DemoIpcA() { Endpoint = "foo.evtA", PropA = "FooFeeFiFoFum" }, _cts.Token);
Examples
There are minimal sample apps: Server ( .Net/Console ), Client ( Winforms/.Net Framework ) and common class library with Dto's in the Examples folder
Project Git Page
| Product | Versions 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. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. 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. |
| .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. |
-
.NETStandard 2.0
- Microsoft.CSharp (>= 4.7.0)
- Microsoft.Extensions.Configuration.Abstractions (>= 10.0.7)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 10.0.7)
- Microsoft.Extensions.Logging.Abstractions (>= 10.0.7)
- System.Text.Json (>= 10.0.7)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on SoM.Ipc:
| Package | Downloads |
|---|---|
|
SoM.WatsonTcp
WatsonTcp connector for use with the SoM.Ipc library. |
GitHub repositories
This package is not used by any popular GitHub repositories.
Added convinience