Client LuaCsForBarotrauma
NetworkConnection.cs
1 using System;
2 
3 namespace Barotrauma.Networking
4 {
6  {
7  Connected = 0x1,
8  Disconnected = 0x2
9  }
10 
11  abstract class NetworkConnection<T> : NetworkConnection where T : Endpoint
12  {
13  protected NetworkConnection(T endpoint) : base(endpoint) { }
14 
15  public new T Endpoint => (base.Endpoint as T)!;
16  }
17 
18  abstract class NetworkConnection
19  {
20  public static double TimeoutThreshold = 60.0; //full minute for timeout because loading screens can take quite a while
21  public static double TimeoutThresholdInGame = 10.0;
22 
23  public AccountInfo AccountInfo { get; private set; } = AccountInfo.None;
24 
25  public readonly Endpoint Endpoint;
26 
27  [Obsolete("TODO: this doesn't belong in layer 1")]
29  {
30  get; set;
31  }
32 
33  protected NetworkConnection(Endpoint endpoint)
34  {
35  Endpoint = endpoint;
36  }
37 
38  public bool EndpointMatches(Endpoint endPoint)
39  => Endpoint == endPoint;
40 
44  public abstract bool AddressMatches(NetworkConnection other);
45 
47 
48  public void SetAccountInfo(AccountInfo newInfo)
49  {
50  if (AccountInfo.IsNone) { AccountInfo = newInfo; }
51  }
52 
53  public sealed override string ToString()
55  }
56 }
abstract string StringRepresentation
Definition: Endpoint.cs:7
abstract bool AddressMatches(NetworkConnection other)
Similar to EndpointMatches but ignores port on LidgrenEndpoint
sealed override string ToString()
void SetAccountInfo(AccountInfo newInfo)
bool EndpointMatches(Endpoint endPoint)
static readonly AccountInfo None
Definition: AccountInfo.cs:10