Class MoongateTCPServer
High-throughput TCP server with client lifecycle events and middleware-enabled payload dispatch.
public sealed class MoongateTCPServer : IAsyncDisposable, IDisposable
- Inheritance
-
MoongateTCPServer
- Implements
- Inherited Members
Constructors
MoongateTCPServer(IPEndPoint, int, int)
Initializes a TCP server bound to the given endpoint.
public MoongateTCPServer(IPEndPoint endPoint, int receiveBufferSize = 8192, int historyBufferCapacity = 65536)
Parameters
endPointIPEndPointEndpoint to bind to. Use port 0 for dynamic port assignment.
receiveBufferSizeintPer-client receive buffer size.
historyBufferCapacityintPer-client circular history capacity.
Properties
Port
Current listening port.
public int Port { get; }
Property Value
Methods
AddMiddleware(INetMiddleware)
Registers middleware in execution order.
public MoongateTCPServer AddMiddleware(INetMiddleware middleware)
Parameters
middlewareINetMiddleware
Returns
Dispose()
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
public void Dispose()
DisposeAsync()
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources asynchronously.
public ValueTask DisposeAsync()
Returns
- ValueTask
A task that represents the asynchronous dispose operation.
StartAsync(CancellationToken)
Starts accepting clients.
public Task StartAsync(CancellationToken cancellationToken)
Parameters
cancellationTokenCancellationToken
Returns
StopAsync(CancellationToken)
Stops accepting new clients and closes all active clients.
public Task StopAsync(CancellationToken cancellationToken)
Parameters
cancellationTokenCancellationToken
Returns
Events
OnClientConnect
Raised when a client connects.
public event EventHandler<MoongateTCPClientEventArgs>? OnClientConnect
Event Type
OnClientDisconnect
Raised when a client disconnects.
public event EventHandler<MoongateTCPClientEventArgs>? OnClientDisconnect
Event Type
OnDataReceived
Raised when a client sends data after middleware processing.
public event EventHandler<MoongateTCPDataReceivedEventArgs>? OnDataReceived
Event Type
OnException
Raised when an exception happens in accept loop or client loops.
public event EventHandler<MoongateTCPExceptionEventArgs>? OnException