(77d1794a) Tester's build January 10th, 2020

This commit is contained in:
juanjp600
2020-01-10 14:42:38 -03:00
parent c02da46ef5
commit e6a08d715b
4529 changed files with 1145046 additions and 218950 deletions
@@ -0,0 +1,37 @@
using System;
using System.Net;
using Lidgren.Network;
namespace Barotrauma.Networking
{
public class LidgrenConnection : NetworkConnection
{
public NetConnection NetConnection { get; private set; }
public IPEndPoint IPEndPoint => NetConnection.RemoteEndPoint;
public string IPString
{
get
{
return IPEndPoint.Address.IsIPv4MappedToIPv6 ? IPEndPoint.Address.MapToIPv4NoThrow().ToString() : IPEndPoint.Address.ToString();
}
}
public UInt16 Port
{
get
{
return (UInt16)IPEndPoint.Port;
}
}
public LidgrenConnection(string name, NetConnection netConnection, UInt64 steamId)
{
Name = name;
NetConnection = netConnection;
SteamID = steamId;
EndPointString = IPString;
}
}
}
@@ -0,0 +1,32 @@
using System;
namespace Barotrauma.Networking
{
public enum NetworkConnectionStatus
{
Connected = 0x1,
Disconnected = 0x2
}
public abstract class NetworkConnection
{
public const double TimeoutThreshold = 60.0; //full minute for timeout because loading screens can take quite a while
public const double TimeoutThresholdInGame = 10.0;
public string Name;
public UInt64 SteamID
{
get;
protected set;
}
public string EndPointString
{
get;
protected set;
}
public NetworkConnectionStatus Status = NetworkConnectionStatus.Disconnected;
}
}
@@ -0,0 +1,13 @@
using System;
namespace Barotrauma.Networking
{
public class PipeConnection : NetworkConnection
{
public PipeConnection()
{
EndPointString = "PIPE";
}
}
}
@@ -0,0 +1,27 @@
using System;
namespace Barotrauma.Networking
{
public class SteamP2PConnection : NetworkConnection
{
public double Timeout = 0.0;
public SteamP2PConnection(string name, UInt64 steamId)
{
SteamID = steamId;
EndPointString = SteamID.ToString();
Name = name;
Heartbeat();
}
public void Decay(float deltaTime)
{
Timeout -= deltaTime;
}
public void Heartbeat()
{
Timeout = TimeoutThreshold;
}
}
}