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
localEndPointIPEndPointThe IPEndPoint of this server's listener socket.
optionsMessageBrokerServerOptionsOptional 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
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
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
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
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
Clients
Collection of attached MessageBrokerRemoteClient instances.
public MessageBrokerRemoteClientCollection Clients { get; }
Property Value
Connectors
Collection of attached MessageBrokerRemoteClientConnector instances.
public MessageBrokerRemoteClientConnectorCollection Connectors { get; }
Property Value
ExpressionFactory
Factory of parsed expressions for listener message filter predicates.
public IParsedExpressionFactory? ExpressionFactory { get; }
Property Value
HandshakeTimeout
Handshake timeout for newly connected clients.
public Duration HandshakeTimeout { get; }
Property Value
LocalEndPoint
The local EndPoint of this server's listener socket.
public EndPoint LocalEndPoint { get; }
Property Value
MaxNetworkMessagePacketLength
Max acceptable network message packet length.
public MemorySize MaxNetworkMessagePacketLength { get; }
Property Value
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
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
State
Current server's state.
public MessageBrokerServerState State { get; }
Property Value
Remarks
See MessageBrokerServerState for more information.
Streams
Collection of attached MessageBrokerStream instances.
public MessageBrokerStreamCollection Streams { get; }
Property Value
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
cancellationTokenCancellationTokenOptional CancellationToken.
Returns
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
cancellationTokenhas 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.