summaryrefslogtreecommitdiff
path: root/Impostor-dev/src/Impostor.Api/Net/IHazelConnection.cs
blob: 4e6c4b3fd03479a18e2a03a816f9f7c3b31d6c17 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
using System.Net;
using System.Threading.Tasks;
using Impostor.Api.Net.Messages;

namespace Impostor.Api.Net
{
    /// <summary>
    ///     Represents the connection of the client.
    /// </summary>
    public interface IHazelConnection
    {
        /// <summary>
        ///     Gets the IP endpoint of the client.
        /// </summary>
        IPEndPoint EndPoint { get; }

        /// <summary>
        ///     Gets a value indicating whether the client is connected to the server.
        /// </summary>
        bool IsConnected { get; }

        /// <summary>
        ///     Gets the client of the connection.
        /// </summary>
        IClient? Client { get; set; }

        /// <summary>
        ///     Sends a message writer to the connection.
        /// </summary>
        /// <param name="writer">The message.</param>
        /// <returns></returns>
        ValueTask SendAsync(IMessageWriter writer);

        /// <summary>
        ///     Disconnects the client and invokes the disconnect handler.
        /// </summary>
        /// <param name="reason">A reason.</param>
        /// <returns></returns>
        ValueTask DisconnectAsync(string? reason);
    }
}