Table of Contents

Interface IRustPlusFcmSocket

Namespace
RustPlusApi.Fcm.Interfaces
Assembly
RustPlusApi.Fcm.dll

Defines the connection lifecycle and notification events for a low-level FCM MCS socket. Clients are disposable; prefer DisposeAsync() so teardown drains background work.

public interface IRustPlusFcmSocket : IDisposable, IAsyncDisposable
Inherited Members

Properties

PersistentIds

A never-null snapshot of the persistentIds currently tracked for de-duplication. Persist and replay these via the constructor to suppress redelivery across reconnects; ids have a server-side lifespan, so pruning your stored copy is your job.

IReadOnlyCollection<string> PersistentIds { get; }

Property Value

IReadOnlyCollection<string>

Remarks

Thread safety: the snapshot enumerates the caller-owned collection with no lock. The receive loop adds ids on its own task, so reading PersistentIds from an unrelated thread while live traffic is flowing can throw InvalidOperationException (collection modified during enumeration). Safe read points: inside a PersistentIdReceived handler or any other notification event (same thread as the harvest), or after Disconnect().

Methods

ConnectAsync(CancellationToken)

Connects to the FCM MCS endpoint and begins receiving notifications. On failure, ErrorOccurred is raised and the exception is rethrown. Instances are single-connection: after Disconnect() or disposal, create a new instance to reconnect.

Task ConnectAsync(CancellationToken cancellationToken = default)

Parameters

cancellationToken CancellationToken

A token to cancel the connection attempt.

Returns

Task

Exceptions

InvalidOperationException

Thrown when the socket is already connected or was closed.

Disconnect()

Cancels the receive loop and releases socket resources.

void Disconnect()

Events

Connected

Raised when the client has successfully connected and logged in.

event EventHandler? Connected

Event Type

EventHandler

Connecting

Raised when the client begins connecting to the FCM server.

event EventHandler? Connecting

Event Type

EventHandler

Disconnected

Raised when the client has fully disconnected.

event EventHandler? Disconnected

Event Type

EventHandler

Disconnecting

Raised when the client begins disconnecting.

event EventHandler? Disconnecting

Event Type

EventHandler

ErrorOccurred

Raised when an unhandled exception occurs on the receive loop.

event EventHandler<Exception>? ErrorOccurred

Event Type

EventHandler<Exception>

NotificationReceived

Raised when a raw FCM notification JSON string is received.

event EventHandler<string>? NotificationReceived

Event Type

EventHandler<string>

PersistentIdReceived

Raised once per newly-harvested FCM persistentId, after it is tracked. Subscribe to persist ids incrementally and minimise the cross-session redelivery window.

event EventHandler<string>? PersistentIdReceived

Event Type

EventHandler<string>

SocketClosed

Raised when the server sends a close tag.

event EventHandler? SocketClosed

Event Type

EventHandler