Skip to content

Commit

Permalink
Remove un-needed latency updating code
Browse files Browse the repository at this point in the history
  • Loading branch information
cubicgraphics committed Apr 1, 2024
1 parent 355656f commit cc72d7c
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 44 deletions.
39 changes: 0 additions & 39 deletions BeatTogether.DedicatedServer.Kernel/DedicatedInstance.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,7 @@
using BeatTogether.DedicatedServer.Messaging.Packets.MultiplayerSession.MPChatPackets;
using BeatTogether.DedicatedServer.Messaging.Packets.MultiplayerSession.MpCorePackets;
using BeatTogether.DedicatedServer.Messaging.Abstractions;

//using BeatTogether.LiteNetLib.Sources;
using BeatTogether.DedicatedServer.Messaging.Util;

//using BeatTogether.LiteNetLib;
//using BeatTogether.LiteNetLib.Abstractions;
//using BeatTogether.LiteNetLib.Configuration;
//using BeatTogether.LiteNetLib.Enums;
//using BeatTogether.LiteNetLib.Util;
//using BeatTogether.LiteNetLib.Sources;
//using Microsoft.Extensions.DependencyInjection;
using Serilog;
using BeatTogether.DedicatedServer.Ignorance.IgnoranceCore;

Expand All @@ -42,7 +32,6 @@ public sealed class DedicatedInstance : ENetServer, IDedicatedInstance
public const int SyncTimeDelay = 5000;

public InstanceConfiguration _configuration { get; private set; }
//public int LiteNetPort => _configuration.LiteNetPort;
public int Port => _configuration.Port;
public bool IsRunning => IsAlive;
public long RunTime => (DateTime.UtcNow.Ticks - _startTime) / 10000L;
Expand All @@ -56,14 +45,12 @@ public sealed class DedicatedInstance : ENetServer, IDedicatedInstance
public event Action<string, bool> GameIsInLobby = null!;
public event Action<IDedicatedInstance> UpdateInstanceEvent = null!;

//private readonly IHandshakeSessionRegistry _handshakeSessionRegistry;
private readonly IPlayerRegistry _playerRegistry;
private readonly IServiceProvider _serviceProvider;
private readonly PacketEncryptionLayer _packetEncryptionLayer;
private readonly IPacketDispatcher PacketDispatcher;
private readonly PacketSource ConnectedMessageSource;

//public SemaphoreSlim ConnectDisconnectSemaphore { get; } = new(1); //Stops lobby loop from running during player connection/disconnection, and stops disconnects and connects happening simultaneously

private byte _connectionIdCount = 0;
private int _lastSortIndex = -1;
Expand All @@ -74,21 +61,14 @@ public sealed class DedicatedInstance : ENetServer, IDedicatedInstance
private long _startTime;
private CancellationTokenSource? _waitForPlayerCts = null;
private CancellationTokenSource? _stopServerCts;



//public readonly ENetServer ENetServer;

public DedicatedInstance(
InstanceConfiguration configuration,
//IHandshakeSessionRegistry handshakeSessionRegistry,
IPlayerRegistry playerRegistry,
//LiteNetConfiguration liteNetConfiguration,
//LiteNetPacketRegistry registry,
IPacketDispatcher packetDispatcher,
PacketSource connectedMessageSource,
IServiceProvider serviceProvider,
//IPacketLayer packetLayer,
PacketEncryptionLayer packetEncryptionLayer)
: base (configuration.Port)
{
Expand Down Expand Up @@ -343,21 +323,6 @@ public void SetState(MultiplayerGameState state)
if (_waitForPlayerCts != null)
_waitForPlayerCts.Cancel();

// Retrieve encryption params and platform data from handshake process by player session token, if provided
//if (!string.IsNullOrEmpty(connectionRequestData.PlayerSessionId))
//{
//var handshakeSession =
// _handshakeSessionRegistry.TryGetByPlayerSessionId(connectionRequestData.PlayerSessionId);
//GetPlayerRegistry().RemoveExtraPlayerSessionData(connectionRequestData.PlayerSessionId, out var ClientVer, out var Platform, out var PlayerPlatformUserId);
//player.ClientVersion = ClientVer;
//player.Platform = (Enums.Platform)Platform;
//player.PlatformUserId = PlayerPlatformUserId;
//if (handshakeSession != null && handshakeSession.EncryptionParameters != null)
//{
// _packetEncryptionLayer.AddEncryptedEndPoint((IPEndPoint)endPoint,
// handshakeSession.EncryptionParameters, true);
//}
//}
if (GetPlayerRegistry().RemoveExtraPlayerSessionData(connectionRequestData.PlayerSessionId, out var ClientVer, out var Platform, out var PlayerPlatformUserId))
{
player.ClientVersion = ClientVer;
Expand Down Expand Up @@ -406,10 +371,6 @@ public override void OnReceive(EndPoint remoteEndPoint, ref SpanBuffer reader, I

#endregion


public override void OnLatencyUpdate(EndPoint endPoint, int latency)
=> _logger.Verbose($"Latency updated (RemoteEndPoint='{endPoint}', Latency={0.001f * latency}).");

public override void OnConnect(EndPoint endPoint)
{
_logger.Information($"Endpoint connected (RemoteEndPoint='{endPoint}')");
Expand Down
5 changes: 0 additions & 5 deletions BeatTogether.DedicatedServer.Kernel/ENet/ENetServer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
using System.Buffers;
using System.Collections.Generic;
using System.Net;
using System.Runtime.InteropServices;
using System.Threading;
using System.Threading.Tasks;
using BeatTogether.DedicatedServer.Ignorance.ENet;
Expand Down Expand Up @@ -327,10 +326,6 @@ public virtual void OnDisconnect(EndPoint endPoint)
{
}

public virtual void OnLatencyUpdate(EndPoint endPoint, int latency)
{
}

public virtual void OnReceive(EndPoint remoteEndPoint, ref SpanBuffer reader, IgnoranceChannelTypes method)
{
}
Expand Down

0 comments on commit cc72d7c

Please sign in to comment.