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
connectionRustPlusConnectionThe server endpoint and player credentials to connect as.
optionsRustPlusSocketOptionsTuning options (timeouts, keep-alive, buffer size); defaults are used when null.
loggerFactoryILoggerFactoryRoutes 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
alarmIdulongThe ID of the alarm entity.
cancellationTokenCancellationTokenA 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
entityIdulongThe ID of the alarm entity.
cancellationTokenCancellationTokenA 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
cancellationTokenCancellationTokenA 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
cancellationTokenCancellationTokenA 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
entityIdulongThe ID of the entity.
selectorFunc<AppMessage, T>The function to select the entity information from the response.
cancellationTokenCancellationTokenA 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
TThe type of the entity information.
GetInfoAsync(CancellationToken)
Retrieves the server information asynchronously.
public Task<Response<ServerInfo?>> GetInfoAsync(CancellationToken cancellationToken = default)
Parameters
cancellationTokenCancellationTokenA 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
cancellationTokenCancellationTokenA 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
cancellationTokenCancellationTokenA 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
appKeystringThe app key for Nexus authentication.
cancellationTokenCancellationTokenA 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
entityIdulongThe ID of the smart switch entity.
cancellationTokenCancellationTokenA 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
entityIdulongThe ID of the storage monitor entity.
cancellationTokenCancellationTokenA 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
cancellationTokenCancellationTokenA 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
cancellationTokenCancellationTokenA 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
cancellationTokenCancellationTokenA 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
broadcastAppBroadcastThe 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
requestAppRequestThe request to be processed.
cancellationTokenCancellationTokenA 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
requestAppRequestThe request to be processed.
successSelectorFunc<AppMessage, T>The function to select the result from the response.
broadcastReplyMatcherFunc<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.Broadcastrather thanresponse.Response. Unrelated broadcasts stay pure notifications.cancellationTokenCancellationTokenA 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
TThe type of the result.
PromoteToLeaderAsync(ulong, CancellationToken)
Promotes a player to leader asynchronously.
public Task<Response> PromoteToLeaderAsync(ulong steamId, CancellationToken cancellationToken = default)
Parameters
steamIdulongThe Steam ID of the player to promote.
cancellationTokenCancellationTokenA 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
buttonsCameraButtonsThe pressed CameraButtons bitmask.
mouseDeltaXfloatThe horizontal mouse delta.
mouseDeltaYfloatThe vertical mouse delta.
cancellationTokenCancellationTokenA 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
messagestringThe message to send.
cancellationTokenCancellationTokenA 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
messagestringThe message to send.
cancellationTokenCancellationTokenA 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
messagestringThe message to set as the clan MOTD.
cancellationTokenCancellationTokenA 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
smartSwitchIdulongThe ID of the smart switch entity.
smartSwitchValueboolThe value to set for the smart switch.
cancellationTokenCancellationTokenA 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
entityIdulongThe ID of the entity.
doSubscribeboolSpecifies whether to subscribe or unsubscribe.
cancellationTokenCancellationTokenA 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
entityIdulongThe ID of the smart switch entity.
timeoutMillisecondsintThe duration of each state in milliseconds.
valueboolThe initial value of the smart switch.
cancellationTokenCancellationTokenA 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
cameraIdstringThe identifier of the camera/CCTV entity to subscribe to.
cancellationTokenCancellationTokenA 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
entityIdulongThe ID of the smart switch entity.
cancellationTokenCancellationTokenA 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
cancellationTokenCancellationTokenA 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
OnClanChanged
Occurs when the clan changes (roles, members, MOTD, …), providing a ClanChangedEventArg.
public event EventHandler<ClanChangedEventArg>? OnClanChanged
Event Type
OnClanChatReceived
Occurs when a clan chat message is received, providing a ClanMessageEventArg.
public event EventHandler<ClanMessageEventArg>? OnClanChatReceived
Event Type
OnSmartSwitchTriggered
Occurs when a SmartSwitchEventArg is triggered by a smart switch or alarm.
public event EventHandler<SmartSwitchEventArg>? OnSmartSwitchTriggered
Event Type
OnStorageMonitorTriggered
Occurs when a StorageMonitorEventArg is triggered by a storage monitor.
public event EventHandler<StorageMonitorEventArg>? OnStorageMonitorTriggered
Event Type
OnTeamChatReceived
Occurs when a team chat message is received, providing a TeamMessageEventArg.
public event EventHandler<TeamMessageEventArg>? OnTeamChatReceived