Orion.Network.Core
0.30.1
dotnet add package Orion.Network.Core --version 0.30.1
NuGet\Install-Package Orion.Network.Core -Version 0.30.1
<PackageReference Include="Orion.Network.Core" Version="0.30.1" />
<PackageVersion Include="Orion.Network.Core" Version="0.30.1" />
<PackageReference Include="Orion.Network.Core" />
paket add Orion.Network.Core --version 0.30.1
#r "nuget: Orion.Network.Core, 0.30.1"
#addin nuget:?package=Orion.Network.Core&version=0.30.1
#tool nuget:?package=Orion.Network.Core&version=0.30.1
Orion.Network.Core
Networking abstractions for the Orion IRC Server project.
IRC is not dead, long live IRC!
About
Orion.Network.Core provides the foundational networking abstraction layer for Orion IRC Server. This library offers a transport-agnostic approach to network communication, allowing the IRC server to work with different transport mechanisms (TCP, WebSockets, etc.) through a unified interface.
Installation
dotnet add package Orion.Network.Core
Or using the Package Manager Console:
Install-Package Orion.Network.Core
Key Features
- Transport Abstraction: Interface-based design for network transports
- Message Handling: Unified message reception and dispatch
- Connection Management: Client connection tracking and lifecycle
- Reactive Design: Event-based communication using System.Reactive
- Protocol-Independent: Works with various network protocols
- Network Data Types: Strong typing for network messages and structures
- Message Parsers: Tools for parsing and processing network messages
Transport System
Orion.Network.Core defines a transport system through the INetworkTransport
interface, allowing different implementations to provide network connectivity:
public interface INetworkTransport
{
event ClientConnectedHandler ClientConnected;
event ClientDisconnectedHandler ClientDisconnected;
event MessageReceivedHandler MessageReceived;
string Id { get; }
string Name { get; }
NetworkProtocolType Protocol { get; }
NetworkSecurityType Security { get; }
ServerNetworkType ServerNetworkType { get; }
string IpAddress { get; }
int Port { get; }
Task StartAsync();
Task StopAsync();
Task SendAsync(string sessionId, byte[] message, CancellationToken cancellationToken = default);
bool HaveSession(string sessionId);
}
Examples
Working with the Transport Manager
using Orion.Network.Core.Interfaces.Services;
using Orion.Network.Core.Data;
using System.Text;
public class NetworkExample
{
private readonly INetworkTransportManager _transportManager;
public NetworkExample(INetworkTransportManager transportManager)
{
_transportManager = transportManager;
// Subscribe to incoming messages
_transportManager.IncomingMessages.Subscribe(HandleIncomingMessage);
// Handle connection events
_transportManager.ClientConnected += OnClientConnected;
_transportManager.ClientDisconnected += OnClientDisconnected;
}
private void OnClientConnected(string transportId, string sessionId, string endpoint)
{
Console.WriteLine($"Client connected: {sessionId} from {endpoint} via {transportId}");
}
private void OnClientDisconnected(string transportId, string sessionId, string endpoint)
{
Console.WriteLine($"Client disconnected: {sessionId} from {endpoint} via {transportId}");
}
private async Task HandleIncomingMessage(NetworkMessageData message)
{
Console.WriteLine($"Message from {message.SessionId}: {message.Message}");
// Send a response
await _transportManager.EnqueueMessageAsync(
new NetworkMessageData(message.SessionId, "Echo: " + message.Message, message.ServerNetworkType)
);
}
}
Implementing a Custom Transport
using Orion.Core.Types;
using Orion.Network.Core.Interfaces.Transports;
using Orion.Network.Core.Types;
public class MyCustomTransport : INetworkTransport
{
public event INetworkTransport.ClientConnectedHandler ClientConnected;
public event INetworkTransport.ClientDisconnectedHandler ClientDisconnected;
public event INetworkTransport.MessageReceivedHandler MessageReceived;
public string Id { get; } = Guid.NewGuid().ToString();
public string Name { get; } = "MyCustomTransport";
public NetworkProtocolType Protocol => NetworkProtocolType.Custom;
public NetworkSecurityType Security => NetworkSecurityType.None;
public ServerNetworkType ServerNetworkType { get; }
public string IpAddress { get; }
public int Port { get; }
private readonly Dictionary<string, MyClient> _clients = new();
public MyCustomTransport(ServerNetworkType serverNetworkType, string ipAddress, int port)
{
ServerNetworkType = serverNetworkType;
IpAddress = ipAddress;
Port = port;
}
public Task StartAsync()
{
// Initialize transport
return Task.CompletedTask;
}
public Task StopAsync()
{
// Shutdown transport
return Task.CompletedTask;
}
public Task SendAsync(string sessionId, byte[] message, CancellationToken cancellationToken = default)
{
if (_clients.TryGetValue(sessionId, out var client))
{
return client.SendAsync(message);
}
throw new InvalidOperationException($"Session {sessionId} not found.");
}
public bool HaveSession(string sessionId)
{
return _clients.ContainsKey(sessionId);
}
// Helper class for the example
private class MyClient
{
public Task SendAsync(byte[] message) => Task.CompletedTask;
}
}
Using the Message Parser
using Orion.Network.Core.Parsers;
// Parse messages from byte buffer
byte[] buffer = Encoding.UTF8.GetBytes("NICK user1\r\nUSER user1 0 * :Real Name\r\n");
var messages = NewLineMessageParser.ParseMessages(buffer);
foreach (var message in messages)
{
Console.WriteLine($"Parsed message: {message}");
}
Dependencies
- Orion.Core: Core utilities and extensions
- Orion.Irc.Core: IRC protocol implementation
- System.Reactive: Reactive programming support
- Microsoft.Extensions.Logging.Abstractions: Logging infrastructure
Related Packages
- Orion.Network.Tcp: TCP implementation for network transports
- Orion.Core.Server: Server-side core functionality
License
This project is licensed under the MIT License - see the LICENSE file for details.
Project Links
- GitHub: https://github.com/tgiachi/orion
- NuGet: [https://www.nuget.org/packages/Orion.Network.Core](https://www.nuget.org/packages/Orion.Network.Core
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net9.0 is compatible. 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. |
-
net9.0
- Microsoft.Extensions.Logging.Abstractions (>= 9.0.4)
- Orion.Foundations (>= 0.30.1)
- System.Reactive (>= 6.0.1)
NuGet packages (2)
Showing the top 2 NuGet packages that depend on Orion.Network.Core:
Package | Downloads |
---|---|
Orion.Network.Tcp
TCP implementation for Orion IRC Server networking |
|
Orion.Core.Server
Server-side core functionality for Orion IRC Server |
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
0.30.1 | 119 | 5/15/2025 |
0.30.0 | 126 | 5/13/2025 |
0.29.0 | 157 | 5/12/2025 |
0.28.4 | 138 | 5/12/2025 |
0.28.3 | 134 | 5/12/2025 |
0.28.2 | 150 | 5/12/2025 |
0.28.1 | 125 | 5/11/2025 |
0.28.0 | 60 | 5/10/2025 |
0.27.1 | 166 | 5/8/2025 |
0.27.0 | 134 | 5/8/2025 |
0.26.0 | 131 | 5/8/2025 |
0.25.2 | 132 | 5/8/2025 |
0.25.1 | 138 | 5/8/2025 |
0.25.0 | 147 | 5/8/2025 |
0.24.0 | 140 | 5/6/2025 |
0.23.0 | 138 | 5/6/2025 |
0.22.3 | 136 | 5/6/2025 |
0.22.2 | 140 | 5/5/2025 |
0.22.0 | 99 | 5/2/2025 |
0.21.0 | 100 | 5/2/2025 |
0.20.0 | 107 | 5/2/2025 |
0.19.1 | 114 | 5/2/2025 |
0.19.0 | 138 | 5/1/2025 |
0.18.1 | 135 | 5/1/2025 |
0.18.0 | 142 | 4/30/2025 |
0.17.0 | 139 | 4/29/2025 |
0.16.0 | 166 | 4/29/2025 |
0.15.0 | 152 | 4/28/2025 |
0.14.3 | 153 | 4/28/2025 |
0.14.2 | 154 | 4/28/2025 |
0.14.1 | 148 | 4/28/2025 |
0.14.0 | 147 | 4/28/2025 |
0.13.0 | 151 | 4/28/2025 |
0.12.3 | 148 | 4/28/2025 |
0.12.2 | 153 | 4/28/2025 |
0.12.1 | 152 | 4/28/2025 |
0.12.0 | 139 | 4/28/2025 |
0.11.1 | 156 | 4/28/2025 |
0.11.0 | 146 | 4/28/2025 |
0.10.0 | 152 | 4/28/2025 |
0.9.0 | 152 | 4/23/2025 |
0.8.0 | 159 | 4/23/2025 |
0.7.0 | 163 | 4/22/2025 |
0.6.1 | 147 | 4/22/2025 |
0.6.0 | 163 | 4/20/2025 |
0.5.0 | 156 | 4/20/2025 |
0.4.0 | 160 | 4/20/2025 |
0.3.0 | 91 | 4/19/2025 |
0.2.0 | 140 | 4/18/2025 |
0.1.10 | 161 | 4/18/2025 |
0.1.9 | 164 | 4/18/2025 |
0.1.8 | 171 | 4/18/2025 |
0.1.7 | 157 | 4/18/2025 |
0.1.6 | 165 | 4/18/2025 |
0.1.5 | 167 | 4/18/2025 |
0.1.4 | 161 | 4/18/2025 |
0.1.3 | 180 | 4/17/2025 |
0.1.2 | 187 | 4/17/2025 |