Table of Contents

Class MessageManager

Namespace
Xabbo.Messages
Assembly
Xabbo.Common.dll

Manages messages between multiple clients using a mapping file.

public sealed class MessageManager : IMessageManager
Inheritance
MessageManager
Implements

Constructors

MessageManager(string?, ILoggerFactory?)

Manages messages between multiple clients using a mapping file.

public MessageManager(string? filePath = null, ILoggerFactory? loggerFactory = null)

Parameters

filePath string
loggerFactory ILoggerFactory

Properties

Available

Gets whether message information is available.

public bool Available { get; }

Property Value

bool

Fetch

Whether to fetch the message map file from the xabbo/messages GitHub repo upon initialization if it does not exist locally.

public bool Fetch { get; set; }

Property Value

bool

MaxAge

The maximum age of the message map file after which it is invalidated.

public TimeSpan MaxAge { get; set; }

Property Value

TimeSpan

Methods

Clear()

public void Clear()

InitializeAsync(CancellationToken)

Initializes the message manager.

public Task InitializeAsync(CancellationToken cancellationToken)

Parameters

cancellationToken CancellationToken

Returns

Task

Is(Header, ReadOnlySpan<Identifier>)

Gets whether the header matches any of the specified identifiers.

public bool Is(Header header, ReadOnlySpan<Identifier> identifiers)

Parameters

header Header
identifiers ReadOnlySpan<Identifier>

Returns

bool

LoadMessages(IEnumerable<ClientMessage>)

Loads the specified client messages.

public void LoadMessages(IEnumerable<ClientMessage> messages)

Parameters

messages IEnumerable<ClientMessage>

Resolve(ReadOnlySpan<Identifier>)

Resolves the specified identifiers to an array of headers.

public Headers Resolve(ReadOnlySpan<Identifier> identifiers)

Parameters

identifiers ReadOnlySpan<Identifier>

Returns

Headers

Exceptions

ArgumentException

If no identifiers were specified.

UnresolvedIdentifiersException

If any of the identifiers could not be resolved.

Resolve(Identifier)

Resolves the specified identifier to a header.

public Header Resolve(Identifier identifier)

Parameters

identifier Identifier

Returns

Header

Exceptions

UnresolvedIdentifiersException

If the identifier could not be resolved.

TryGetHeader(Identifier, out Header)

Attempts to get a header by its identifier.

public bool TryGetHeader(Identifier identifier, out Header header)

Parameters

identifier Identifier
header Header

Returns

bool

TryGetNames(Header, out MessageNames)

Attempts to get the associated message names for the specified header.

public bool TryGetNames(Header header, out MessageNames identifiers)

Parameters

header Header
identifiers MessageNames

Returns

bool

TryGetNames(Identifier, out MessageNames)

Attempts to get the associated message names for the specified identifier.

public bool TryGetNames(Identifier identifier, out MessageNames names)

Parameters

identifier Identifier
names MessageNames

Returns

bool

TryResolve(ReadOnlySpan<Identifier>, out Headers?, out Identifiers?)

Attempts to resolve the specified identifiers to an array of headers.

public bool TryResolve(ReadOnlySpan<Identifier> identifiers, out Headers? headers, out Identifiers? unresolved)

Parameters

identifiers ReadOnlySpan<Identifier>
headers Headers
unresolved Identifiers

Returns

bool

Exceptions

ArgumentException

If no identifiers were specified.

Events

Loaded

Notifies listeners when messages have been loaded.

public event Action? Loaded

Event Type

Action