(a00338777) v0.9.2.1

This commit is contained in:
Joonas Rikkonen
2019-08-26 19:58:19 +03:00
parent 0f63da27b2
commit 80698b58b0
311 changed files with 11763 additions and 4507 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.MapToIPv4().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;
using System.Collections.Generic;
using System.Text;
using System.Net;
namespace Barotrauma.Networking
{
public enum NetworkConnectionStatus
{
Connected = 0x1,
Disconnected = 0x2
}
public abstract class NetworkConnection
{
public string Name;
public UInt64 SteamID
{
get;
protected set;
}
public string EndPointString
{
get;
protected set;
}
public NetworkConnectionStatus Status = NetworkConnectionStatus.Disconnected;
}
}
@@ -0,0 +1,29 @@
using System;
using System.Collections.Generic;
using System.Text;
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 = 20.0;
}
}
}