Interface IRustPlusSocket
- Namespace
- RustPlusApi.Interfaces
- Assembly
- RustPlusApi.dll
Low-level WebSocket contract โ connection lifecycle and raw message events. Clients are disposable; prefer DisposeAsync() so teardown drains background work.
public interface IRustPlusSocket : IDisposable, IAsyncDisposable
- Inherited Members
Properties
IsConnected
Gets a value indicating whether the WebSocket connection is currently open.
bool IsConnected { get; }
Property Value
Methods
ConnectAsync(CancellationToken)
Opens the WebSocket connection to the server. On failure, ErrorOccurred is raised
and the exception is rethrown. May be called again after a disconnect to reconnect.
Task ConnectAsync(CancellationToken cancellationToken = default)
Parameters
cancellationTokenCancellationTokenA token to cancel the connection attempt.
Returns
Exceptions
- ObjectDisposedException
Thrown when the client has been disposed.
- InvalidOperationException
Thrown when the client is already connected.
DisconnectAsync(bool)
Closes the WebSocket connection.
Task DisconnectAsync(bool forceClose = false)
Parameters
Returns
Events
Connected
Raised when the WebSocket connection is established.
event EventHandler? Connected
Event Type
Connecting
Raised just before the WebSocket connection attempt begins.
event EventHandler? Connecting
Event Type
Disconnected
Raised after the WebSocket connection has been closed.
event EventHandler? Disconnected
Event Type
Disconnecting
Raised just before the WebSocket connection is closed.
event EventHandler? Disconnecting
Event Type
ErrorOccurred
Raised when an unhandled exception occurs on the receive loop.
event EventHandler<Exception>? ErrorOccurred
Event Type
MessageReceived
Raised for every inbound AppMessage, before routing.
event EventHandler<AppMessage>? MessageReceived
Event Type
- EventHandler<AppMessage>
NotificationReceived
Raised for inbound messages that are push notifications (no matching pending request).
event EventHandler<AppMessage>? NotificationReceived
Event Type
- EventHandler<AppMessage>
RequestSent
Raised after a request has been serialized and sent.
event EventHandler<AppRequest>? RequestSent
Event Type
- EventHandler<AppRequest>
ResponseReceived
Raised for inbound messages that are responses to a pending request.
event EventHandler<AppMessage>? ResponseReceived
Event Type
- EventHandler<AppMessage>
SendingRequest
Raised when a request is about to be sent to the server.
event EventHandler? SendingRequest