Table of Contents

Class TerminalUdpRouter

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

The default ITerminalRouter<TContext> for UDP server communication.

public sealed class TerminalUdpRouter : ITerminalRouter<TerminalUdpRouterContext>
Inheritance
TerminalUdpRouter
Implements
Inherited Members

Remarks

This class implements the ITerminalRouter<TContext> interface and is responsible for handling UDP server communication. It runs a terminal as a UDP server on the specified IP endpoint and listens for incoming UDP datagrams. Unlike TCP, UDP is connectionless, allowing this server to receive messages from multiple clients without establishing a dedicated connection for each. Messages can be received and processed concurrently from various sources, making UDP suitable for scenarios where low latency or high-throughput communication is required, albeit with the trade-off of reliability.

The server can be gracefully stopped by canceling the provided cancellation token in the context, ensuring any ongoing operations are terminated and resources are cleanly released.

Constructors

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

Initializes a new instance of the TerminalUdpRouter class.

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

Parameters

commandRouter ICommandRouter

The command router to route commands to.

exceptionHandler ITerminalExceptionHandler

The handler for exceptions that occur during routing.

options TerminalOptions

Configuration options for the terminal.

textHandler ITerminalTextHandler

The handler for processing text data.

logger ILogger<TerminalUdpRouter>

The logger for logging information and errors.

Methods

RunAsync(TerminalUdpRouterContext)

Asynchronously runs the UDP router, listening for incoming UDP packets and processing them.

public Task RunAsync(TerminalUdpRouterContext context)

Parameters

context TerminalUdpRouterContext

The UDP router context containing configuration and runtime information.

Returns

Task

A task that represents the asynchronous operation.

See Also