(a00338777) v0.9.2.1
This commit is contained in:
+37
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
+32
@@ -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;
|
||||
}
|
||||
}
|
||||
+29
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user