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
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
cancellationTokenCancellationTokenA token to cancel the connection attempt.
Returns
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
Connecting
Raised when the client begins connecting to the FCM server.
event EventHandler? Connecting
Event Type
Disconnected
Raised when the client has fully disconnected.
event EventHandler? Disconnected
Event Type
Disconnecting
Raised when the client begins disconnecting.
event EventHandler? Disconnecting
Event Type
ErrorOccurred
Raised when an unhandled exception occurs on the receive loop.
event EventHandler<Exception>? ErrorOccurred
Event Type
NotificationReceived
Raised when a raw FCM notification JSON string is received.
event EventHandler<string>? NotificationReceived
Event Type
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
SocketClosed
Raised when the server sends a close tag.
event EventHandler? SocketClosed