From e9ea621b93fbb58d9edfca8375918791637bbd52 Mon Sep 17 00:00:00 2001 From: chai Date: Wed, 30 Dec 2020 20:59:04 +0800 Subject: +init --- Impostor-dev/src/Impostor.Api/Net/IClient.cs | 76 ++++++++++++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100644 Impostor-dev/src/Impostor.Api/Net/IClient.cs (limited to 'Impostor-dev/src/Impostor.Api/Net/IClient.cs') diff --git a/Impostor-dev/src/Impostor.Api/Net/IClient.cs b/Impostor-dev/src/Impostor.Api/Net/IClient.cs new file mode 100644 index 0000000..48efeda --- /dev/null +++ b/Impostor-dev/src/Impostor.Api/Net/IClient.cs @@ -0,0 +1,76 @@ +using System.Collections.Generic; +using System.Threading.Tasks; +using Impostor.Api.Innersloth; +using Impostor.Api.Net.Messages; + +namespace Impostor.Api.Net +{ + /// + /// Represents a connected game client. + /// + public interface IClient + { + /// + /// Gets or sets the unique ID of the client. + /// + /// + /// This ID is generated when the client is registered in the client manager and should not be used + /// to store persisted data. + /// + int Id { get; set; } + + /// + /// Gets the name that was provided by the player in the client. + /// + /// + /// The name is provided by the player and should not be used to store persisted data. + /// + string Name { get; } + + /// + /// Gets the connection of the client. + /// + /// + /// Null when the client was not registered by the matchmaker. + /// + IHazelConnection? Connection { get; } + + /// + /// Gets a key/value collection that can be used to share data between messages. + /// + /// + /// + /// The stored data will not be saved. + /// After the connection has been closed all data will be lost. + /// + /// + /// Note that the values will not be disposed after the connection has been closed. + /// This has to be implemented by the plugin. + /// + /// + IDictionary Items { get; } + + /// + /// Gets or sets the current game data of the . + /// + IClientPlayer? Player { get; } + + ValueTask HandleMessageAsync(IMessageReader message, MessageType messageType); + + ValueTask HandleDisconnectAsync(string reason); + + /// + /// Disconnect the client with a . + /// + /// + /// The message to show to the player. + /// + /// + /// Only used when is set to . + /// + /// + /// A representing the asynchronous operation. + /// + ValueTask DisconnectAsync(DisconnectReason reason, string? message = null); + } +} -- cgit v1.1-26-g67d0