IPCPipeline 1.0.0
See the version list below for details.
dotnet add package IPCPipeline --version 1.0.0
NuGet\Install-Package IPCPipeline -Version 1.0.0
<PackageReference Include="IPCPipeline" Version="1.0.0" />
paket add IPCPipeline --version 1.0.0
#r "nuget: IPCPipeline, 1.0.0"
// Install IPCPipeline as a Cake Addin #addin nuget:?package=IPCPipeline&version=1.0.0 // Install IPCPipeline as a Cake Tool #tool nuget:?package=IPCPipeline&version=1.0.0
IPCPipeline (front-end for Cloudtoid Interprocess)
Inter-process bi-directional communication pipeline (IPC) or (IPBDC) that can both write and read data at the same time. This uses cloudtoid/interprocess as its low-level backend API.
This project is based on Cloudtoid/Interprocess and is for the ones that do not want to spend time on writing a wrapper for their project to use that library.
What can it do?
It wraps the necessary classes to only one class called IPCPipeline which you can use for both writing and reading in a channel. We use Newtonsoft.Json for sending and receiving data over Cloidtoid Interprocess library. This makes it easy to read any object or data in a subscriber.
Due to JSON and other circumstances, this library will slightly be slower than the original low-level library. So if speed is a concern for you (if your project is as sensitive as nanoseconds or less than 2 milliseconds), then do not use this project. Use the original, low-level version at https://github.com/cloudtoid/interprocess.
Usage
This library supports .NET Core 3.1+ and .NET 6+.
Create a Publisher and Send Message to Subscribers
Creating an instance of IPCPipeline with the name of the channel and access mode as a publisher:
var pipe = new IPCPipeline("myChannel", PipeAccess.Write);
Send a message from the publisher to subscribers:
var response = pipe.SendMessage(data);
if (response.IsSuccess)
{
// ...
}
Create a Subscriber and read messages coming from Publishers
Creating an instance of IPCPipeline with the name of the channel used to create the publisher:
var pipe = new IPCPipeline("myChannel", PipeAccess.Read);
Receive messages from publishers:
pipe.OnMessageReceived += (msgid, data) =>
{
var data = data.ToObject<PipelineData>();
Console.WriteLine("[{0}] Data \"{1}\" received.", data.SentAt, data.Name);
return System.Threading.Tasks.Task.CompletedTask;
};
Send Primitive Types rather than Objects
If you do not want to create custom classes, you can use the built-in primitive type data classes to send messages to subscribers.
Here's an example about sending a string:
pipe.SendMessage("myStringMessageName", "the text you want to send");
Here's an example about sending a bool:
pipe.SendMessage("myBoolMessageName", true);
Here's an example about sending a float:
pipe.SendMessage("myFloatMessageName", 0.5f);
Here's an example about sending a byte array:
pipe.SendMessage("myByteArrayMessageName", System.IO.File.ReadAllBytes("myImage.png")); // Make sure the buffer is big enough in subscriber's IPCPipeline class instance.
Receiving any of these values is as easy as shown above:
pipe.OnMessageReceived += (msgid, data) =>
{
var data = data.ToObject<PipelineData>();
if (data.Name == "myStringMessageName")
{
var textData = data.ToObject<PipelineStringData>();
Console.WriteLine("Received string: {0}", textData.Value);
}
};
Sample
To see a sample implementation of a publisher and a subscriber process, try out the following two projects. You can run them side by side and see them in action:
More Information
The rest is almost the same as the original library, so check it at https://github.com/cloudtoid/interprocess.
Discord Server
Join our Discord server at here to discuss about this or the main library and get help from other members like you.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 is compatible. 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 is compatible. 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 | netcoreapp3.1 is compatible. |
-
.NETCoreApp 3.1
- Cloudtoid.Interprocess (>= 1.0.175)
- Newtonsoft.Json (>= 13.0.3)
-
net6.0
- Cloudtoid.Interprocess (>= 1.0.175)
- Newtonsoft.Json (>= 13.0.3)
-
net7.0
- Cloudtoid.Interprocess (>= 1.0.175)
- Newtonsoft.Json (>= 13.0.3)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.