quakeball/Assets/Scripts/Net/Connection.cs
2020-08-05 04:21:04 +03:00

38 lines
1.3 KiB
C#

using System.Collections;
using System.Collections.Generic;
using System.Net;
using System;
using NeonTea.Quakeball.Net.Packets;
namespace NeonTea.Quakeball.Net {
public class Connection {
public IPEndPoint Endpoint;
public ConnectionStatus Status;
public byte AssignedProtocol;
public ClosingReason ClosingReason;
public long LastMessage;
public int LatestPacketSent; // Last Packet ID the connection has told us they have
public int LatestPacketReceived; // Last Packet ID we've received from the connection
public int PacketIDCounter; // 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
}
}