Show / Hide Table of Contents

Class ConsoleConnector

Implements the IMessageConnector for console-based communication. This interface allows the agent to send and receive messages through the system console. Messages are displayed in the format [Sender] Content, and user input is captured when Enter is pressed.

Inheritance
object
ConsoleConnector
Implements
IMessageConnector
Inherited Members
object.Equals(object)
object.Equals(object, object)
object.GetHashCode()
object.GetType()
object.MemberwiseClone()
object.ReferenceEquals(object, object)
object.ToString()
Namespace: VulcanAI.Connectors
Assembly: VulcanAI.dll
Syntax
public class ConsoleConnector : IMessageConnector
Remarks

The ConsoleInterface provides a simple way to interact with the agent through the command line. It runs a background task to continuously read user input and raises events when messages are received. All operations are asynchronous and include proper logging for debugging and monitoring.

Constructors

| Edit this page View Source

ConsoleConnector(ILogger<ConsoleConnector>)

Initializes a new instance of the ConsoleConnector class.

Declaration
public ConsoleConnector(ILogger<ConsoleConnector> logger)
Parameters
Type Name Description
ILogger<ConsoleConnector> logger

The logger instance for recording diagnostic information.

Exceptions
Type Condition
ArgumentNullException

Thrown when the logger parameter is null.

Methods

| Edit this page View Source

SendMessageAsync(string)

Declaration
public Task SendMessageAsync(string content)
Parameters
Type Name Description
string content
Returns
Type Description
Task
| Edit this page View Source

SendMessageAsync(Message)

Sends a message to the console output.

Declaration
public Task SendMessageAsync(Message message)
Parameters
Type Name Description
Message message

The message to send.

Returns
Type Description
Task

A task representing the asynchronous operation.

Remarks

Messages are displayed in the format [Sender] Content. This method is thread-safe and can be called from any thread.

| Edit this page View Source

StartAsync()

Starts the console interface and begins listening for user input.

Declaration
public Task StartAsync()
Returns
Type Description
Task

A task representing the asynchronous operation.

Remarks

This method starts a background task that continuously reads input from the console. If the interface is already running, this method returns immediately.

| Edit this page View Source

StopAsync()

Stops the console interface and stops listening for user input.

Declaration
public Task StopAsync()
Returns
Type Description
Task

A task representing the asynchronous operation.

Remarks

This method stops the background input reading task and waits for it to complete. If the interface is not running, this method returns immediately.

Events

| Edit this page View Source

OnMessageReceived

Occurs when a message is received from the console input.

Declaration
public event EventHandler<Message>? OnMessageReceived
Event Type
Type Description
EventHandler<Message>
Remarks

This event is raised whenever the user types a message and presses Enter. The message sender is set to "User" and the channel is set to "Console".

Implements

IMessageConnector
  • Edit this page
  • View Source
In this article
Back to top Generated by DocFX