Skip to content

Interface IPlayerService

Namespace: Void.Proxy.Api.Players
Assembly: Void.Proxy.Api.dll

Provides operations for managing instances.

public interface IPlayerService

Extension Methods

PlayerServiceExtensions.TryGetByName(IPlayerService, string, out IPlayer?)

Properties

All

Gets a collection containing all active players.

IEnumerable<IPlayer> All { get; }

Property Value

IEnumerable<IPlayer>

Methods

AcceptPlayerAsync(TcpClient, CancellationToken)

Accepts a new connection and creates a player instance from the provided .

ValueTask AcceptPlayerAsync(TcpClient client, CancellationToken cancellationToken = default)

Parameters

client TcpClient

The client representing the player connection.

cancellationToken CancellationToken

Token used to cancel the operation.

Returns

ValueTask

ForEach(Action<IPlayer>)

Executes the specified action for each player.

void ForEach(Action<IPlayer> action)

Parameters

action Action<IPlayer>

The action to perform for each player.

ForEachAsync(Func<IPlayer, CancellationToken, ValueTask>, CancellationToken)

Executes the specified asynchronous action for each player.

ValueTask ForEachAsync(Func<IPlayer, CancellationToken, ValueTask> action, CancellationToken cancellationToken = default)

Parameters

action Func<IPlayer, CancellationToken, ValueTask>

The asynchronous action to execute for each player.

cancellationToken CancellationToken

Token used to cancel the operation.

Returns

ValueTask

KickPlayerAsync(IPlayer, string?, CancellationToken)

Kicks a player with an optional message.

ValueTask KickPlayerAsync(IPlayer player, string? text = null, CancellationToken cancellationToken = default)

Parameters

player IPlayer

The player to kick.

text string?

The optional kick message.

cancellationToken CancellationToken

Token used to cancel the operation.

Returns

ValueTask

KickPlayerAsync(IPlayer, PlayerKickEvent, CancellationToken)

Kicks a player using a instance.

ValueTask KickPlayerAsync(IPlayer player, PlayerKickEvent playerKickEvent, CancellationToken cancellationToken = default)

Parameters

player IPlayer

The player to kick.

playerKickEvent PlayerKickEvent

The event describing the kick.

cancellationToken CancellationToken

Token used to cancel the operation.

Returns

ValueTask

UpgradeAsync(IPlayer, IPlayer, CancellationToken)

Upgrades the specified player to upgradedPlayer.

ValueTask UpgradeAsync(IPlayer player, IPlayer upgradedPlayer, CancellationToken cancellationToken)

Parameters

player IPlayer

The current player instance.

upgradedPlayer IPlayer

The upgraded player instance.

cancellationToken CancellationToken

Token used to cancel the operation.

Returns

ValueTask