Table of Contents

Class TerminalTcpRouter

Namespace
OneImlx.Terminal.Runtime
Assembly
OneImlx.Terminal.dll

The default ITerminalRouter<TContext> for TCP client-server communication.

public class TerminalTcpRouter : ITerminalRouter<TerminalTcpRouterContext>
Inheritance
TerminalTcpRouter
Implements
Inherited Members

Remarks

This class implements the ITerminalRouter<TContext> interface and is responsible for handling TCP client-server communication. It runs a terminal as a TCP server on the specified endpoint and waits for incoming client connections. The server can be gracefully stopped by triggering a cancellation token in the context.

Constructors

TerminalTcpRouter(ICommandRouter, ITerminalExceptionHandler, TerminalOptions, ITerminalTextHandler, ILogger<TerminalTcpRouter>)

Initializes a new instance of the TerminalTcpRouter class.

public TerminalTcpRouter(ICommandRouter commandRouter, ITerminalExceptionHandler exceptionHandler, TerminalOptions options, ITerminalTextHandler textHandler, ILogger<TerminalTcpRouter> logger)

Parameters

commandRouter ICommandRouter

The command router.

exceptionHandler ITerminalExceptionHandler

The exception handler.

options TerminalOptions

The configuration options.

textHandler ITerminalTextHandler

The text handler.

logger ILogger<TerminalTcpRouter>

The logger.

Remarks

This constructor creates a new instance of the TerminalTcpRouter class. It takes several dependencies that are required for handling TCP client-server communication.

Methods

RunAsync(TerminalTcpRouterContext)

Runs the TCP server for handling client connections asynchronously.

public virtual Task RunAsync(TerminalTcpRouterContext context)

Parameters

context TerminalTcpRouterContext

The routing context.

Returns

Task

A task representing the asynchronous operation.

Remarks

This method starts a TCP server on the specified IP endpoint and waits for incoming client connections. It handles the client connections asynchronously by creating a task for each incoming connection. The server can be gracefully stopped by canceling the provided cancellation token in the context. The method will also stop if an exception is encountered while handling client connections.

See Also