MaxLatency added

This commit is contained in:
EntenKoeniq 2022-01-01 15:58:14 +01:00
parent 5ee477e857
commit 42903a1b53
3 changed files with 16 additions and 2 deletions

View File

@ -8,7 +8,20 @@ namespace CoopServer
public class Client public class Client
{ {
public long NetHandle = 0; public long NetHandle = 0;
public float Latency = 0.0f; private float CurrentLatency = 0f;
public float Latency
{
get => CurrentLatency;
internal set
{
CurrentLatency = value;
if ((value * 1000f) > Server.MainSettings.MaxLatency)
{
Server.MainNetServer.Connections.Find(x => x.RemoteUniqueIdentifier == NetHandle)?.Disconnect($"Too high latency [{value * 1000f}/{(float)Server.MainSettings.MaxLatency}]");
}
}
}
public PlayerData Player; public PlayerData Player;
private readonly Dictionary<string, object> CustomData = new(); private readonly Dictionary<string, object> CustomData = new();
private long CallbacksCount = 0; private long CallbacksCount = 0;

View File

@ -3,7 +3,7 @@
<PropertyGroup> <PropertyGroup>
<OutputType>Exe</OutputType> <OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework> <TargetFramework>net6.0</TargetFramework>
<AssemblyVersion>1.42.0.0001</AssemblyVersion> <AssemblyVersion>1.43.0.0001</AssemblyVersion>
<FileVersion>1.0.0.0</FileVersion> <FileVersion>1.0.0.0</FileVersion>
<RepositoryUrl>https://github.com/GTACOOP-R/GTACoop-R</RepositoryUrl> <RepositoryUrl>https://github.com/GTACOOP-R/GTACoop-R</RepositoryUrl>
</PropertyGroup> </PropertyGroup>

View File

@ -4,6 +4,7 @@
{ {
public int Port { get; set; } = 4499; public int Port { get; set; } = 4499;
public int MaxPlayers { get; set; } = 16; public int MaxPlayers { get; set; } = 16;
public int MaxLatency { get; set; } = 300;
public string Name { get; set; } = "GTACoop:R server"; public string Name { get; set; } = "GTACoop:R server";
public string WelcomeMessage { get; set; } = "Welcome on this server :)"; public string WelcomeMessage { get; set; } = "Welcome on this server :)";
public string Resource { get; set; } = ""; public string Resource { get; set; } = "";