first commit
This commit is contained in:
19
NitroxClient/Communication/Abstract/IClient.cs
Normal file
19
NitroxClient/Communication/Abstract/IClient.cs
Normal 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);
|
||||
}
|
||||
}
|
21
NitroxClient/Communication/Abstract/IMultiplayerSession.cs
Normal file
21
NitroxClient/Communication/Abstract/IMultiplayerSession.cs
Normal 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();
|
||||
}
|
||||
}
|
@@ -0,0 +1,8 @@
|
||||
namespace NitroxClient.Communication.Abstract
|
||||
{
|
||||
public interface IMultiplayerSessionConnectionContext : IMultiplayerSessionState
|
||||
{
|
||||
void UpdateConnectionState(IMultiplayerSessionConnectionState sessionConnectionState);
|
||||
void ClearSessionState();
|
||||
}
|
||||
}
|
@@ -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);
|
||||
}
|
||||
}
|
@@ -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; }
|
||||
}
|
||||
}
|
13
NitroxClient/Communication/Abstract/IPacketSender.cs
Normal file
13
NitroxClient/Communication/Abstract/IPacketSender.cs
Normal 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;
|
||||
}
|
Reference in New Issue
Block a user