Table of Contents

Class RustPlus

Namespace
RustPlusApi
Assembly
RustPlusApi.dll

Initializes a new instance of the RustPlus class, connecting to a Rust+ server using the specified parameters.

public class RustPlus : RustPlusSocket, IRustPlus, IRustPlusSocket, IDisposable, IAsyncDisposable
Inheritance
RustPlus
Implements
Inherited Members

Constructors

RustPlus(RustPlusConnection, RustPlusSocketOptions?, ILoggerFactory?)

Initializes a new instance of the RustPlus class, connecting to a Rust+ server using the specified parameters.

public RustPlus(RustPlusConnection connection, RustPlusSocketOptions? options = null, ILoggerFactory? loggerFactory = null)

Parameters

connection RustPlusConnection

The server endpoint and player credentials to connect as.

options RustPlusSocketOptions

Tuning options (timeouts, keep-alive, buffer size); defaults are used when null.

loggerFactory ILoggerFactory

Routes the client's diagnostics into your logging stack; logging is disabled (a no-op NullLogger) when null.

See Also

Methods

CheckSubscriptionAsync(ulong, CancellationToken)

Checks the subscription status of an alarm asynchronously.

public Task<Response<SubscriptionInfo?>> CheckSubscriptionAsync(ulong alarmId, CancellationToken cancellationToken = default)

Parameters

alarmId ulong

The ID of the alarm entity.

cancellationToken CancellationToken

A token to observe for cancellation requests.

Returns

Task<Response<SubscriptionInfo>>

A Task<TResult> representing the asynchronous operation. The task result contains a Response<T> with the subscription information.

GetAlarmInfoAsync(ulong, CancellationToken)

Retrieves the information of an alarm asynchronously.

public Task<Response<AlarmInfo?>> GetAlarmInfoAsync(ulong entityId, CancellationToken cancellationToken = default)

Parameters

entityId ulong

The ID of the alarm entity.

cancellationToken CancellationToken

A token to observe for cancellation requests.

Returns

Task<Response<AlarmInfo>>

A Task<TResult> representing the asynchronous operation. The task result contains a Response<T> with the alarm information.

GetClanChatAsync(CancellationToken)

Retrieves the clan chat asynchronously.

public Task<Response<ClanChatInfo?>> GetClanChatAsync(CancellationToken cancellationToken = default)

Parameters

cancellationToken CancellationToken

A token to observe for cancellation requests.

Returns

Task<Response<ClanChatInfo>>

A Task<TResult> representing the asynchronous operation. The task result contains a Response<T> with the clan chat information.

GetClanInfoAsync(CancellationToken)

Retrieves the clan information asynchronously.

public Task<Response<ClanInfo?>> GetClanInfoAsync(CancellationToken cancellationToken = default)

Parameters

cancellationToken CancellationToken

A token to observe for cancellation requests.

Returns

Task<Response<ClanInfo>>

A Task<TResult> representing the asynchronous operation. The task result contains a Response<T> with the clan information.

GetEntityInfoAsync<T>(ulong, Func<AppMessage, T>, CancellationToken)

Retrieves the information of an entity asynchronously.

protected Task<Response<T?>> GetEntityInfoAsync<T>(ulong entityId, Func<AppMessage, T> selector, CancellationToken cancellationToken = default)

Parameters

entityId ulong

The ID of the entity.

selector Func<AppMessage, T>

The function to select the entity information from the response.

cancellationToken CancellationToken

A token to observe for cancellation requests.

Returns

Task<Response<T>>

A Task<TResult> representing the asynchronous operation. The task result contains a Response<T> with the entity information.

Type Parameters

T

The type of the entity information.

GetInfoAsync(CancellationToken)

Retrieves the server information asynchronously.

public Task<Response<ServerInfo?>> GetInfoAsync(CancellationToken cancellationToken = default)

Parameters

cancellationToken CancellationToken

A token to observe for cancellation requests.

Returns

Task<Response<ServerInfo>>

A Task<TResult> representing the asynchronous operation. The task result contains a Response<T> with the server information.

GetMapAsync(CancellationToken)

Retrieves the server map asynchronously.

public Task<Response<ServerMap?>> GetMapAsync(CancellationToken cancellationToken = default)

Parameters

cancellationToken CancellationToken

A token to observe for cancellation requests.

Returns

Task<Response<ServerMap>>

A Task<TResult> representing the asynchronous operation. The task result contains a Response<T> with the server map.

GetMapMarkersAsync(CancellationToken)

Retrieves the map markers asynchronously.

public Task<Response<MapMarkers?>> GetMapMarkersAsync(CancellationToken cancellationToken = default)

Parameters

cancellationToken CancellationToken

A token to observe for cancellation requests.

Returns

Task<Response<MapMarkers>>

A Task<TResult> representing the asynchronous operation. The task result contains a Response<T> with the map markers.

GetNexusAuthAsync(string, CancellationToken)

Retrieves the Nexus authentication asynchronously.

public Task<Response<NexusAuth?>> GetNexusAuthAsync(string appKey, CancellationToken cancellationToken = default)

Parameters

appKey string

The app key for Nexus authentication.

cancellationToken CancellationToken

A token to observe for cancellation requests.

Returns

Task<Response<NexusAuth>>

A Task<TResult> representing the asynchronous operation. The task result contains a Response<T> with the Nexus authentication.

GetSmartSwitchInfoAsync(ulong, CancellationToken)

Retrieves the information of a smart switch asynchronously.

public Task<Response<SmartSwitchInfo?>> GetSmartSwitchInfoAsync(ulong entityId, CancellationToken cancellationToken = default)

Parameters

entityId ulong

The ID of the smart switch entity.

cancellationToken CancellationToken

A token to observe for cancellation requests.

Returns

Task<Response<SmartSwitchInfo>>

A Task<TResult> representing the asynchronous operation. The task result contains a Response<T> with the smart switch information.

GetStorageMonitorInfoAsync(ulong, CancellationToken)

Retrieves the information of a storage monitor asynchronously.

public Task<Response<StorageMonitorInfo?>> GetStorageMonitorInfoAsync(ulong entityId, CancellationToken cancellationToken = default)

Parameters

entityId ulong

The ID of the storage monitor entity.

cancellationToken CancellationToken

A token to observe for cancellation requests.

Returns

Task<Response<StorageMonitorInfo>>

A Task<TResult> representing the asynchronous operation. The task result contains a Response<T> with the storage monitor information.

GetTeamChatAsync(CancellationToken)

Retrieves the team chat information asynchronously.

public Task<Response<TeamChatInfo?>> GetTeamChatAsync(CancellationToken cancellationToken = default)

Parameters

cancellationToken CancellationToken

A token to observe for cancellation requests.

Returns

Task<Response<TeamChatInfo>>

A Task<TResult> representing the asynchronous operation. The task result contains a Response<T> with the team chat information.

GetTeamInfoAsync(CancellationToken)

Retrieves the team information asynchronously.

public Task<Response<TeamInfo?>> GetTeamInfoAsync(CancellationToken cancellationToken = default)

Parameters

cancellationToken CancellationToken

A token to observe for cancellation requests.

Returns

Task<Response<TeamInfo>>

A Task<TResult> representing the asynchronous operation. The task result contains a Response<T> with the team information.

GetTimeAsync(CancellationToken)

Retrieves the current time information asynchronously.

public Task<Response<TimeInfo?>> GetTimeAsync(CancellationToken cancellationToken = default)

Parameters

cancellationToken CancellationToken

A token to observe for cancellation requests.

Returns

Task<Response<TimeInfo>>

A Task<TResult> representing the asynchronous operation. The task result contains a Response<T> with the time information.

ParseNotification(AppBroadcast?)

Parses the notification received from the Rust+ server.

protected override void ParseNotification(AppBroadcast? broadcast)

Parameters

broadcast AppBroadcast

The broadcast received from the server.

ProcessAckRequestAsync(AppRequest, CancellationToken)

Processes an acknowledge-only request asynchronously: success is the absence of a server error, and no payload is returned.

protected Task<Response> ProcessAckRequestAsync(AppRequest request, CancellationToken cancellationToken = default)

Parameters

request AppRequest

The request to be processed.

cancellationToken CancellationToken

A token to observe for cancellation requests.

Returns

Task<Response>

A Task<TResult> whose result is a payload-free Response.

ProcessRequestAsync<T>(AppRequest, Func<AppMessage, T>, Func<AppBroadcast, bool>?, CancellationToken)

Processes the request asynchronously and returns the result.

protected Task<Response<T?>> ProcessRequestAsync<T>(AppRequest request, Func<AppMessage, T> successSelector, Func<AppBroadcast, bool>? broadcastReplyMatcher = null, CancellationToken cancellationToken = default)

Parameters

request AppRequest

The request to be processed.

successSelector Func<AppMessage, T>

The function to select the result from the response.

broadcastReplyMatcher Func<AppBroadcast, bool>

When non-null, the success reply is delivered as a broadcast (no seq) and is matched by this predicate, so the selector reads response.Broadcast rather than response.Response. Unrelated broadcasts stay pure notifications.

cancellationToken CancellationToken

A token to observe for cancellation requests.

Returns

Task<Response<T>>

A Task<TResult> representing the asynchronous operation. The task result contains a Response<T> with the processed result.

Type Parameters

T

The type of the result.

PromoteToLeaderAsync(ulong, CancellationToken)

Promotes a player to leader asynchronously.

public Task<Response> PromoteToLeaderAsync(ulong steamId, CancellationToken cancellationToken = default)

Parameters

steamId ulong

The Steam ID of the player to promote.

cancellationToken CancellationToken

A token to observe for cancellation requests.

Returns

Task<Response>

A Task<TResult> representing the asynchronous operation. The task result contains a payload-free Response indicating the success of the operation.

SendCameraInputAsync(CameraButtons, float, float, CancellationToken)

Sends input (movement/mouse/buttons) to the subscribed camera asynchronously.

public Task<Response> SendCameraInputAsync(CameraButtons buttons, float mouseDeltaX = 0, float mouseDeltaY = 0, CancellationToken cancellationToken = default)

Parameters

buttons CameraButtons

The pressed CameraButtons bitmask.

mouseDeltaX float

The horizontal mouse delta.

mouseDeltaY float

The vertical mouse delta.

cancellationToken CancellationToken

A token to observe for cancellation requests.

Returns

Task<Response>

A Task<TResult> representing the asynchronous operation. The task result contains a payload-free Response indicating the success of the operation.

SendClanMessageAsync(string, CancellationToken)

Sends a clan message asynchronously.

public Task<Response> SendClanMessageAsync(string message, CancellationToken cancellationToken = default)

Parameters

message string

The message to send.

cancellationToken CancellationToken

A token to observe for cancellation requests.

Returns

Task<Response>

A Task<TResult> representing the asynchronous operation. The task result contains a payload-free Response indicating the success of the operation.

SendTeamMessageAsync(string, CancellationToken)

Sends a team message asynchronously.

public Task<Response<TeamMessage?>> SendTeamMessageAsync(string message, CancellationToken cancellationToken = default)

Parameters

message string

The message to send.

cancellationToken CancellationToken

A token to observe for cancellation requests.

Returns

Task<Response<TeamMessage>>

A Task<TResult> representing the asynchronous operation. The task result contains a Response<T> with the team message.

SetClanMotdAsync(string, CancellationToken)

Sets the clan message of the day (MOTD) asynchronously.

public Task<Response> SetClanMotdAsync(string message, CancellationToken cancellationToken = default)

Parameters

message string

The message to set as the clan MOTD.

cancellationToken CancellationToken

A token to observe for cancellation requests.

Returns

Task<Response>

A Task<TResult> representing the asynchronous operation. The task result contains a payload-free Response indicating the success of the operation.

SetSmartSwitchValueAsync(ulong, bool, CancellationToken)

Sets the value of a smart switch asynchronously.

public Task<Response<SmartSwitchInfo?>> SetSmartSwitchValueAsync(ulong smartSwitchId, bool smartSwitchValue, CancellationToken cancellationToken = default)

Parameters

smartSwitchId ulong

The ID of the smart switch entity.

smartSwitchValue bool

The value to set for the smart switch.

cancellationToken CancellationToken

A token to observe for cancellation requests.

Returns

Task<Response<SmartSwitchInfo>>

A Task<TResult> representing the asynchronous operation. The task result contains a Response<T> with the updated smart switch information.

SetSubscriptionAsync(ulong, bool, CancellationToken)

Sets the subscription status of an entity asynchronously.

public Task<Response> SetSubscriptionAsync(ulong entityId, bool doSubscribe = true, CancellationToken cancellationToken = default)

Parameters

entityId ulong

The ID of the entity.

doSubscribe bool

Specifies whether to subscribe or unsubscribe.

cancellationToken CancellationToken

A token to observe for cancellation requests.

Returns

Task<Response>

A Task<TResult> representing the asynchronous operation. The task result contains a payload-free Response indicating the success of the operation.

StrobeSmartSwitchAsync(ulong, int, bool, CancellationToken)

Strobes a smart switch asynchronously.

public Task<Response<SmartSwitchInfo?>> StrobeSmartSwitchAsync(ulong entityId, int timeoutMilliseconds = 1000, bool value = true, CancellationToken cancellationToken = default)

Parameters

entityId ulong

The ID of the smart switch entity.

timeoutMilliseconds int

The duration of each state in milliseconds.

value bool

The initial value of the smart switch.

cancellationToken CancellationToken

A token to observe for cancellation requests.

Returns

Task<Response<SmartSwitchInfo>>

A Task<TResult> representing the asynchronous operation. The task result contains a Response<T> with the updated smart switch information.

SubscribeToCameraAsync(string, CancellationToken)

Subscribes to a camera asynchronously, starting the OnCameraRaysReceived stream.

public Task<Response<CameraInfo?>> SubscribeToCameraAsync(string cameraId, CancellationToken cancellationToken = default)

Parameters

cameraId string

The identifier of the camera/CCTV entity to subscribe to.

cancellationToken CancellationToken

A token to observe for cancellation requests.

Returns

Task<Response<CameraInfo>>

A Task<TResult> representing the asynchronous operation. The task result contains a Response<T> with the camera information.

ToggleSmartSwitchAsync(ulong, CancellationToken)

Toggles a smart switch asynchronously.

public Task<Response<SmartSwitchInfo?>> ToggleSmartSwitchAsync(ulong entityId, CancellationToken cancellationToken = default)

Parameters

entityId ulong

The ID of the smart switch entity.

cancellationToken CancellationToken

A token to observe for cancellation requests.

Returns

Task<Response<SmartSwitchInfo>>

A Task<TResult> representing the asynchronous operation. The task result contains a Response<T> with the updated smart switch information.

UnsubscribeFromCameraAsync(CancellationToken)

Unsubscribes from the currently subscribed camera asynchronously.

public Task<Response> UnsubscribeFromCameraAsync(CancellationToken cancellationToken = default)

Parameters

cancellationToken CancellationToken

A token to observe for cancellation requests.

Returns

Task<Response>

A Task<TResult> representing the asynchronous operation. The task result contains a payload-free Response indicating the success of the operation.

Events

OnCameraRaysReceived

Occurs when a camera frame is received for the subscribed camera, providing a CameraRaysEventArg.

public event EventHandler<CameraRaysEventArg>? OnCameraRaysReceived

Event Type

EventHandler<CameraRaysEventArg>

OnClanChanged

Occurs when the clan changes (roles, members, MOTD, …), providing a ClanChangedEventArg.

public event EventHandler<ClanChangedEventArg>? OnClanChanged

Event Type

EventHandler<ClanChangedEventArg>

OnClanChatReceived

Occurs when a clan chat message is received, providing a ClanMessageEventArg.

public event EventHandler<ClanMessageEventArg>? OnClanChatReceived

Event Type

EventHandler<ClanMessageEventArg>

OnSmartSwitchTriggered

Occurs when a SmartSwitchEventArg is triggered by a smart switch or alarm.

public event EventHandler<SmartSwitchEventArg>? OnSmartSwitchTriggered

Event Type

EventHandler<SmartSwitchEventArg>

OnStorageMonitorTriggered

Occurs when a StorageMonitorEventArg is triggered by a storage monitor.

public event EventHandler<StorageMonitorEventArg>? OnStorageMonitorTriggered

Event Type

EventHandler<StorageMonitorEventArg>

OnTeamChatReceived

Occurs when a team chat message is received, providing a TeamMessageEventArg.

public event EventHandler<TeamMessageEventArg>? OnTeamChatReceived

Event Type

EventHandler<TeamMessageEventArg>

See Also