CodeWF.EventBus.Socket
1.2.0
dotnet add package CodeWF.EventBus.Socket --version 1.2.0
NuGet\Install-Package CodeWF.EventBus.Socket -Version 1.2.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="CodeWF.EventBus.Socket" Version="1.2.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="CodeWF.EventBus.Socket" Version="1.2.0" />
<PackageReference Include="CodeWF.EventBus.Socket" />
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add CodeWF.EventBus.Socket --version 1.2.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: CodeWF.EventBus.Socket, 1.2.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.
#:package CodeWF.EventBus.Socket@1.2.0
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=CodeWF.EventBus.Socket&version=1.2.0
#tool nuget:?package=CodeWF.EventBus.Socket&version=1.2.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
CodeWF.EventBus.Socket
English | 简体中文
CodeWF.EventBus.Socket is a lightweight TCP event bus for C# processes. It provides Publish/Subscribe messaging and Query-style request/response over sockets, so local processes or lightweight services can communicate without introducing RabbitMQ, Kafka, Redis, or other external MQ infrastructure.
Highlights
- TCP socket transport based on
CodeWF.NetWrapper - Publish/Subscribe for cross-process notifications
- Query/response flow on the same subject
- Query correlation by request
TaskId, including concurrent queries on the same subject - Reuses
CodeWF.NetWrappertransport objects such asTcpSocketServer,TcpSocketClient,SocketCommand, andHeartbeat - No external MQ dependency
- Demo application in
src/EventBusDemo
Installation
dotnet add package CodeWF.EventBus.Socket
or
Install-Package CodeWF.EventBus.Socket
Quick Start
Start the server
using CodeWF.EventBus.Socket;
IEventServer eventServer = new EventServer();
await eventServer.StartAsync("127.0.0.1", 9100);
Connect a client
using CodeWF.EventBus.Socket;
IEventClient eventClient = new EventClient();
await eventClient.ConnectAsync("127.0.0.1", 9100);
Subscribe and publish
eventClient.Subscribe<NewEmailCommand>("event.email.new", command =>
{
Console.WriteLine($"Received: {command.Subject}");
});
eventClient.Publish("event.email.new", new NewEmailCommand
{
Subject = "Welcome",
Content = "Your account is ready",
SendTime = DateTime.Now
}, out _);
Query and respond
eventClient.Subscribe<EmailQuery>("event.email.query", query =>
{
var response = new EmailQueryResponse
{
Emails = EmailManager.QueryEmail(query.Subject)
};
eventClient.Publish("event.email.query", response, out _);
});
var result = await eventClient.QueryAsync<EmailQuery, EmailQueryResponse>(
"event.email.query",
new EmailQuery { Subject = "Account" },
3000);
Documentation
Communication Protocol
Data packets are exchanged over TCP.
Notes
- This library is designed for lightweight event distribution and IPC-style communication.
- The transport layer is implemented with
CodeWF.NetWrapper, and same-name transport objects are reused directly instead of being duplicated locally. - Event-bus-specific request/query/update packets remain defined in this project because they carry library-specific semantics.
- Messages are kept in memory only. There is no persistence, broker-side retry queue, or delivery guarantee after a process restart.
- For production use, consider whether you need authentication, encryption, retry, monitoring, and back-pressure around the socket transport.
| 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. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net10.0
- CodeWF.NetWrapper (>= 2.1.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.