v1.3.0.1 (Epic Store release)
This commit is contained in:
+8
@@ -0,0 +1,8 @@
|
||||
#nullable enable
|
||||
|
||||
namespace Barotrauma.Networking;
|
||||
|
||||
sealed class EosP2PConnection : P2PConnection<EosP2PEndpoint>
|
||||
{
|
||||
public EosP2PConnection(EosP2PEndpoint endpoint) : base(endpoint) { }
|
||||
}
|
||||
+1
-1
@@ -2,7 +2,7 @@
|
||||
|
||||
namespace Barotrauma.Networking
|
||||
{
|
||||
sealed class LidgrenConnection : NetworkConnection
|
||||
sealed class LidgrenConnection : NetworkConnection<LidgrenEndpoint>
|
||||
{
|
||||
public readonly NetConnection NetConnection;
|
||||
|
||||
|
||||
+10
-3
@@ -8,6 +8,13 @@ namespace Barotrauma.Networking
|
||||
Disconnected = 0x2
|
||||
}
|
||||
|
||||
abstract class NetworkConnection<T> : NetworkConnection where T : Endpoint
|
||||
{
|
||||
protected NetworkConnection(T endpoint) : base(endpoint) { }
|
||||
|
||||
public new T Endpoint => (base.Endpoint as T)!;
|
||||
}
|
||||
|
||||
abstract class NetworkConnection
|
||||
{
|
||||
public const double TimeoutThreshold = 60.0; //full minute for timeout because loading screens can take quite a while
|
||||
@@ -23,7 +30,7 @@ namespace Barotrauma.Networking
|
||||
get; set;
|
||||
}
|
||||
|
||||
public NetworkConnection(Endpoint endpoint)
|
||||
protected NetworkConnection(Endpoint endpoint)
|
||||
{
|
||||
Endpoint = endpoint;
|
||||
}
|
||||
@@ -35,9 +42,9 @@ namespace Barotrauma.Networking
|
||||
|
||||
public void SetAccountInfo(AccountInfo newInfo)
|
||||
{
|
||||
AccountInfo = newInfo;
|
||||
if (AccountInfo.IsNone) { AccountInfo = newInfo; }
|
||||
}
|
||||
|
||||
|
||||
public sealed override string ToString()
|
||||
=> Endpoint.StringRepresentation;
|
||||
}
|
||||
|
||||
+30
@@ -0,0 +1,30 @@
|
||||
#nullable enable
|
||||
|
||||
namespace Barotrauma.Networking;
|
||||
|
||||
abstract class P2PConnection<T> : P2PConnection where T : P2PEndpoint
|
||||
{
|
||||
protected P2PConnection(T endpoint) : base(endpoint) { }
|
||||
|
||||
public new T Endpoint => (base.Endpoint as T)!;
|
||||
}
|
||||
|
||||
abstract class P2PConnection : NetworkConnection<P2PEndpoint>
|
||||
{
|
||||
protected P2PConnection(P2PEndpoint endpoint) : base(endpoint)
|
||||
{
|
||||
Heartbeat();
|
||||
}
|
||||
|
||||
public double Timeout = 0.0;
|
||||
|
||||
public void Decay(float deltaTime)
|
||||
{
|
||||
Timeout -= deltaTime;
|
||||
}
|
||||
|
||||
public void Heartbeat()
|
||||
{
|
||||
Timeout = TimeoutThreshold;
|
||||
}
|
||||
}
|
||||
+3
-3
@@ -23,11 +23,11 @@ namespace Barotrauma.Networking
|
||||
=> !(a == b);
|
||||
}
|
||||
|
||||
sealed class PipeConnection : NetworkConnection
|
||||
sealed class PipeConnection : NetworkConnection<PipeEndpoint>
|
||||
{
|
||||
public PipeConnection(AccountId accountId) : base(new PipeEndpoint())
|
||||
public PipeConnection(Option<AccountId> accountId) : base(new PipeEndpoint())
|
||||
{
|
||||
SetAccountInfo(new AccountInfo(Option<AccountId>.Some(accountId)));
|
||||
SetAccountInfo(new AccountInfo(accountId));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+2
-17
@@ -1,24 +1,9 @@
|
||||
namespace Barotrauma.Networking
|
||||
{
|
||||
sealed class SteamP2PConnection : NetworkConnection
|
||||
sealed class SteamP2PConnection : P2PConnection<SteamP2PEndpoint>
|
||||
{
|
||||
public double Timeout = 0.0;
|
||||
|
||||
public SteamP2PConnection(SteamId steamId) : this(new SteamP2PEndpoint(steamId)) { }
|
||||
|
||||
public SteamP2PConnection(SteamP2PEndpoint endpoint) : base(endpoint)
|
||||
{
|
||||
Heartbeat();
|
||||
}
|
||||
|
||||
public void Decay(float deltaTime)
|
||||
{
|
||||
Timeout -= deltaTime;
|
||||
}
|
||||
|
||||
public void Heartbeat()
|
||||
{
|
||||
Timeout = TimeoutThreshold;
|
||||
}
|
||||
public SteamP2PConnection(SteamP2PEndpoint endpoint) : base(endpoint) { }
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user