first commit

This commit is contained in:
2025-07-06 00:23:46 +02:00
commit 38f50c8819
1788 changed files with 112878 additions and 0 deletions

View File

@@ -0,0 +1,19 @@
using System.Threading.Tasks;
using NitroxModel.Packets;
namespace NitroxClient.Communication.Abstract
{
/// <summary>
/// Abstracted IClient in order to give us options in the underlying protocol that we use to communicate with the server.
/// Ex: We may want to also roll a UDP client in the future to handle packets where we don't necessarily care
/// about transmission order or error recovery.
/// </summary>
public interface IClient
{
bool IsConnected { get; }
Task StartAsync(string ipAddress, int serverPort);
void Stop();
void PollEvents();
void Send(Packet packet);
}
}

View File

@@ -0,0 +1,21 @@
using System.Threading.Tasks;
using NitroxModel.MultiplayerSession;
using NitroxModel.Packets;
namespace NitroxClient.Communication.Abstract
{
public delegate void MultiplayerSessionConnectionStateChangedEventHandler(IMultiplayerSessionConnectionState newState);
public interface IMultiplayerSession : IPacketSender, IMultiplayerSessionState
{
IMultiplayerSessionConnectionState CurrentState { get; }
event MultiplayerSessionConnectionStateChangedEventHandler ConnectionStateChanged;
Task ConnectAsync(string ipAddress, int port);
void ProcessSessionPolicy(MultiplayerSessionPolicy policy);
void RequestSessionReservation(PlayerSettings playerSettings, AuthenticationContext authenticationContext);
void ProcessReservationResponsePacket(MultiplayerSessionReservation reservation);
void JoinSession();
void Disconnect();
}
}

View File

@@ -0,0 +1,8 @@
namespace NitroxClient.Communication.Abstract
{
public interface IMultiplayerSessionConnectionContext : IMultiplayerSessionState
{
void UpdateConnectionState(IMultiplayerSessionConnectionState sessionConnectionState);
void ClearSessionState();
}
}

View File

@@ -0,0 +1,14 @@
using System.Threading.Tasks;
using NitroxClient.Communication.MultiplayerSession;
namespace NitroxClient.Communication.Abstract
{
public interface IMultiplayerSessionConnectionState
{
MultiplayerSessionConnectionStage CurrentStage { get; }
Task NegotiateReservationAsync(IMultiplayerSessionConnectionContext sessionConnectionContext);
void JoinSession(IMultiplayerSessionConnectionContext sessionConnectionContext);
void Disconnect(IMultiplayerSessionConnectionContext sessionConnectionContext);
}
}

View File

@@ -0,0 +1,16 @@
using NitroxModel.MultiplayerSession;
using NitroxModel.Packets;
namespace NitroxClient.Communication.Abstract
{
public interface IMultiplayerSessionState
{
IClient Client { get; }
string IpAddress { get; }
int ServerPort { get; }
MultiplayerSessionPolicy SessionPolicy { get; }
PlayerSettings PlayerSettings { get; }
AuthenticationContext AuthenticationContext { get; }
MultiplayerSessionReservation Reservation { get; }
}
}

View File

@@ -0,0 +1,13 @@
using NitroxModel.Packets;
namespace NitroxClient.Communication.Abstract;
public interface IPacketSender
{
/// <summary>
/// Sends the packet. Returns true if packet was not suppressed.
/// </summary>
/// <param name="packet">The packet to send.</param>
/// <returns>True if not suppressed and actually sent.</returns>
bool Send<T>(T packet) where T : Packet;
}