Table of Contents

Class MessageBrokerServer

Namespace
LfrlAnvil.MessageBroker.Server
Assembly
LfrlAnvil.MessageBroker.Server.dll

Represents a message broker server.

public sealed class MessageBrokerServer : IDisposable, IAsyncDisposable
Inheritance
MessageBrokerServer
Implements
Inherited Members

Constructors

MessageBrokerServer(IPEndPoint, MessageBrokerServerOptions)

Creates a new MessageBrokerServer instance.

public MessageBrokerServer(IPEndPoint localEndPoint, MessageBrokerServerOptions options = default)

Parameters

localEndPoint IPEndPoint

The IPEndPoint of this server's listener socket.

options MessageBrokerServerOptions

Optional creation options.

Properties

AcceptableMaxBatchPacketCount

Range of acceptable max number of packets in a single network batch packet values.

public Bounds<short> AcceptableMaxBatchPacketCount { get; }

Property Value

Bounds<short>

Remarks

Acts as a limit imposed on client's desired max batch packet count during handshake.

AcceptableMaxNetworkBatchPacketLength

Range of acceptable max network batch packet length values.

public Bounds<MemorySize> AcceptableMaxNetworkBatchPacketLength { get; }

Property Value

Bounds<MemorySize>

Remarks

Represents a range of max possible length values for packets of Batch type. Acts as a limit imposed on client's desired max network batch packet length during handshake.

AcceptableMessageTimeout

Range of acceptable send or receive message timeout values.

public Bounds<Duration> AcceptableMessageTimeout { get; }

Property Value

Bounds<Duration>

Remarks

Acts as a limit imposed on client's desired message timeout during handshake.

AcceptablePingInterval

Range of acceptable send ping interval values.

public Bounds<Duration> AcceptablePingInterval { get; }

Property Value

Bounds<Duration>

Remarks

Acts as a limit imposed on client's desired ping interval during handshake.

Channels

Collection of attached MessageBrokerChannel instances.

public MessageBrokerChannelCollection Channels { get; }

Property Value

MessageBrokerChannelCollection

Clients

Collection of attached MessageBrokerRemoteClient instances.

public MessageBrokerRemoteClientCollection Clients { get; }

Property Value

MessageBrokerRemoteClientCollection

Connectors

Collection of attached MessageBrokerRemoteClientConnector instances.

public MessageBrokerRemoteClientConnectorCollection Connectors { get; }

Property Value

MessageBrokerRemoteClientConnectorCollection

ExpressionFactory

Factory of parsed expressions for listener message filter predicates.

public IParsedExpressionFactory? ExpressionFactory { get; }

Property Value

IParsedExpressionFactory

HandshakeTimeout

Handshake timeout for newly connected clients.

public Duration HandshakeTimeout { get; }

Property Value

Duration

LocalEndPoint

The local EndPoint of this server's listener socket.

public EndPoint LocalEndPoint { get; }

Property Value

EndPoint

MaxNetworkMessagePacketLength

Max acceptable network message packet length.

public MemorySize MaxNetworkMessagePacketLength { get; }

Property Value

MemorySize

Remarks

Represents max possible length for outbound packets of MessageNotification type or inbound packets of PushMessage type.

MaxNetworkPacketLength

Max acceptable network packet length.

public MemorySize MaxNetworkPacketLength { get; }

Property Value

MemorySize

Remarks

Represents max possible length for packets not handled by either MaxNetworkMessagePacketLength or MaxNetworkBatchPacketLength.

RootStorageDirectoryPath

Specifies the root directory for permanent server storage. Lack of root directory will cause the server to be ephemeral and work in in-memory mode.

public string? RootStorageDirectoryPath { get; }

Property Value

string

State

Current server's state.

public MessageBrokerServerState State { get; }

Property Value

MessageBrokerServerState

Remarks

See MessageBrokerServerState for more information.

Streams

Collection of attached MessageBrokerStream instances.

public MessageBrokerStreamCollection Streams { get; }

Property Value

MessageBrokerStreamCollection

Methods

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)

Attempts to initialize the server and start listening for client connections.

public ValueTask<Result> StartAsync(CancellationToken cancellationToken = default)

Parameters

cancellationToken CancellationToken

Optional CancellationToken.

Returns

ValueTask<Result>

A task that represents the operation, which returns a Result instance.

Remarks

Errors encountered during server initialization will cause it to be automatically disposed. Returned Result will only be valid when the server will successfully start listening for client connections and proceed to the Running state.

Exceptions

OperationCanceledException

When cancellationToken has been cancelled.

MessageBrokerServerDisposedException

When this server has already been disposed.

MessageBrokerServerStateException

When this server is not disposed and not in Created state.

ToString()

Returns a string representation of this MessageBrokerServer instance.

[Pure]
public override string ToString()

Returns

string

String representation.