Add channel system with CLI, Telegram, and Web channel implementations
Define channel abstractions (IChannel, IChannelManager) with event-driven message and connection handling. Implement ChannelManager for multi-channel orchestration, CliChannel for terminal I/O, TelegramChannel with adapter pattern for bot API integration, and WebChannel stub. Includes DI registration and channel type enumeration.
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
namespace Luna.Channels.Abstractions;
|
||||
|
||||
/// <summary>
|
||||
/// Manages the lifecycle and routing of all registered communication channels.
|
||||
/// </summary>
|
||||
public interface IChannelManager
|
||||
{
|
||||
/// <summary>
|
||||
/// Registers a channel with this manager.
|
||||
/// </summary>
|
||||
/// <param name="channel"></param>
|
||||
/// <exception cref="InvalidOperationException">Thrown if a channel with the same ID is already registered.</exception>
|
||||
void RegisterChannel(IChannel channel);
|
||||
|
||||
/// <summary>
|
||||
/// Unregisters a channel by its ID. No-op if the channel is not found.
|
||||
/// </summary>
|
||||
/// <param name="channelId">The ID of the channel to remove.</param>
|
||||
void UnregisterChannel(string channelId);
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves a registered channel by its ID.
|
||||
/// </summary>
|
||||
/// <param name="channelId">The ID of the channel to retrieve.</param>
|
||||
/// <returns>The channel, or null if not found.</returns>
|
||||
IChannel? GetChannel(string channelId);
|
||||
|
||||
/// <summary>
|
||||
/// Returns all currently registered channels.
|
||||
/// </summary>
|
||||
IReadOnlyList<IChannel> GetAllChannels();
|
||||
|
||||
/// <summary>
|
||||
/// Raised after a message has been received and routed.
|
||||
/// </summary>
|
||||
event EventHandler<ChannelMessageReceivedEventArgs>? MessageRouted;
|
||||
}
|
||||
Reference in New Issue
Block a user