(61d00a474) v0.9.7.1

This commit is contained in:
Regalis
2020-03-04 13:04:10 +01:00
parent 3c50efa5c9
commit 3c09ebe02f
5086 changed files with 786063 additions and 295871 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;
}
}
}