Skip to content

Commit

Permalink
First pass of removing compat for older versions
Browse files Browse the repository at this point in the history
  • Loading branch information
zlee007-Aaron committed Mar 30, 2024
1 parent 0124fed commit 0fbcfee
Show file tree
Hide file tree
Showing 88 changed files with 356 additions and 2,252 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ public record CreateMatchmakingServerResponse(
CreateMatchmakingServerError Error,
string? RemoteEndPoint = null,
byte[]? Random = null,
byte[]? PublicKey = null,
string? RemoteEndPointENet = null)
byte[]? PublicKey = null)
{
public bool Success => Error == default;
}
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
using BeatTogether.LiteNetLib.Abstractions;
using System.Threading.Tasks;

namespace BeatTogether.DedicatedServer.Kernel.Abstractions
{
public abstract class BasePacketHandler<TPacket> : IPacketHandler<TPacket>
where TPacket : class, INetSerializable
{
public abstract Task Handle(IPlayer sender, TPacket packet);
public abstract void Handle(IPlayer sender, TPacket packet);

public Task Handle(IPlayer sender, INetSerializable packet) =>
public void Handle(IPlayer sender, INetSerializable packet) =>
Handle(sender, (TPacket)packet);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,18 @@ public interface IDedicatedInstance
event Action<string, EndPoint, string[]> PlayerDisconnectBeforeJoining;
event Action<string, bool> GameIsInLobby;
event Action<IDedicatedInstance> UpdateInstanceEvent;
SemaphoreSlim ConnectDisconnectSemaphore { get; }

void InstanceConfigUpdated();
InstanceConfiguration _configuration { get; }
bool IsRunning { get; }
long RunTime { get; }
public int LiteNetPort { get; }
public int ENetPort { get; }
//public int LiteNetPort { get; }
public int Port { get; }
MultiplayerGameState State { get; }

float NoPlayersTime { get; }

IHandshakeSessionRegistry GetHandshakeSessionRegistry();
//IHandshakeSessionRegistry GetHandshakeSessionRegistry();
IPlayerRegistry GetPlayerRegistry();
IServiceProvider GetServiceProvider();

Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using BeatTogether.LiteNetLib.Abstractions;
using BeatTogether.LiteNetLib.Enums;
using System.Threading.Tasks;

namespace BeatTogether.DedicatedServer.Kernel.Abstractions
{
Expand All @@ -17,7 +16,7 @@ public interface IPacketDispatcher
void SendFromPlayer(IPlayer fromPlayer, INetSerializable packet, DeliveryMethod deliveryMethod);
void SendFromPlayer(IPlayer fromPlayer, INetSerializable[] packets, DeliveryMethod deliveryMethod);


/*
Task SendToNearbyPlayersAndAwait(INetSerializable packet, DeliveryMethod deliveryMethod);
Task SendToNearbyPlayersAndAwait(INetSerializable[] packets, DeliveryMethod deliveryMethod);
Task SendExcludingPlayerAndAwait(IPlayer excludedPlayer, INetSerializable packet, DeliveryMethod deliveryMethod);
Expand All @@ -28,5 +27,6 @@ public interface IPacketDispatcher
Task SendFromPlayerToPlayerAndAwait(IPlayer fromPlayer, IPlayer toPlayer, INetSerializable[] packets, DeliveryMethod deliveryMethod);
Task SendToPlayerAndAwait(IPlayer player, INetSerializable packet, DeliveryMethod deliveryMethod);
Task SendToPlayerAndAwait(IPlayer player, INetSerializable[] packets, DeliveryMethod deliveryMethod);
*/
}
}
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
using BeatTogether.LiteNetLib.Abstractions;
using System.Threading.Tasks;

namespace BeatTogether.DedicatedServer.Kernel.Abstractions
{
public interface IPacketHandler
{
Task Handle(IPlayer sender, INetSerializable packet);
void Handle(IPlayer sender, INetSerializable packet);
}

public interface IPacketHandler<TPacket> : IPacketHandler
where TPacket : class, INetSerializable
{
Task Handle(IPlayer sender, TPacket packet);
void Handle(IPlayer sender, TPacket packet);
}
}
8 changes: 2 additions & 6 deletions BeatTogether.DedicatedServer.Kernel/Abstractions/IPlayer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,18 @@
using BeatTogether.DedicatedServer.Kernel.Types;
using BeatTogether.DedicatedServer.Messaging.Enums;
using BeatTogether.DedicatedServer.Messaging.Models;
using System.Threading;
using System.Threading.Tasks;

namespace BeatTogether.DedicatedServer.Kernel.Abstractions
{
public interface IPlayer
{
SemaphoreSlim PlayerAccessSemaphore { get; set; }
EndPoint Endpoint { get; }
IDedicatedInstance Instance { get; }
byte ConnectionId { get; }
byte RemoteConnectionId { get; }
string Secret { get; }
string UserId { get; }
string UserName { get; }
string? PlayerSessionId { get; }
string PlayerSessionId { get; }

byte[]? Random { get; set; }
byte[]? PublicEncryptionKey { get; set; }
Expand All @@ -27,7 +23,7 @@ public interface IPlayer
string PlatformUserId { get; set; }

uint? ENetPeerId { get; set; }
bool IsENetConnection => ENetPeerId.HasValue;
bool IsENetConnection { get;}

RollingAverage Latency { get; }
long SyncTime { get; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,8 @@ public interface IPlayerRegistry
bool TryGetPlayer(byte connectionId, [MaybeNullWhen(false)] out IPlayer player);
bool TryGetPlayer(string userId, [MaybeNullWhen(false)] out IPlayer player);
int GetMillisBetweenSyncStatePackets();

public void AddExtraPlayerSessionData(string playerSessionId, string ClientVersion, byte PlatformId, string PlayerPlatformUserId);
public bool RemoveExtraPlayerSessionData(string playerSessionId, out string ClientVersion, out byte Platform, out string PlayerPlatformUserId);
}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ namespace BeatTogether.DedicatedServer.Kernel.Configuration
{
public sealed class InstanceConfiguration
{
public int LiteNetPort { get; set; }
public int ENetPort { get; set; }
//public int LiteNetPort { get; set; }
public int Port { get; set; }
public string Secret { get; set; } = string.Empty;
public string ServerOwnerId { get; set; } = string.Empty;
public string ServerId { get; set; } = "ziuMSceapEuNN7wRGQXrZg";
Expand Down
Loading

0 comments on commit 0fbcfee

Please sign in to comment.