using System.Collections; using System.Collections.Generic; using System.Net; using System; using NeonTea.Quakeball.TeaNet.Packets; namespace NeonTea.Quakeball.TeaNet.Peers { public class Connection { public IPEndPoint Endpoint; public ConnectionStatus Status; public byte AssignedProtocol; public ClosingReason ClosingReason; public long LastMessage; public int LatestOutwardReliable = -1; // Last reliable Packet ID the connection has told us they have public int LatestOutwardUnreliable = -1; // Last unreliablePacket ID the connection has told us they have public int LatestInwardReliable = -1; // Last reliable Packet ID we've received from the connection public int LatestInwardUnreliable = -1; // Last unreliable Packet ID we've received from the connection public int ReliablePacketIDCounter; // Reliable Packet ID counter for packets we're sending them public int UnreliablePacketIDCounter; // Unreliable Packet ID counter for packets we're sending them public Connection(IPEndPoint endpoint, ConnectionStatus status = ConnectionStatus.Establishing) { Endpoint = endpoint; Status = status; LastMessage = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds(); } } public enum ConnectionStatus { Awaiting, // Awaiting an establishing Establishing, // Attempting to establish Ready, // Ready for packet sending Rejected, // Rejected connection at endpoint, sending Rejected Closed, // Closed connection at endpoint, sending Closed Stopped, // Not sending packages Lost, // Connection Lost } }