2020-08-02 02:50:01 +02:00
|
|
|
|
using System.Collections;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Net;
|
2020-08-05 03:21:04 +02:00
|
|
|
|
using System;
|
|
|
|
|
|
|
|
|
|
using NeonTea.Quakeball.Net.Packets;
|
2020-08-02 02:50:01 +02:00
|
|
|
|
|
|
|
|
|
namespace NeonTea.Quakeball.Net {
|
|
|
|
|
public class Connection {
|
|
|
|
|
|
|
|
|
|
public IPEndPoint Endpoint;
|
2020-08-05 03:21:04 +02:00
|
|
|
|
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
|
2020-08-02 02:50:01 +02:00
|
|
|
|
|
2020-08-05 03:21:04 +02:00
|
|
|
|
public Connection(IPEndPoint endpoint, ConnectionStatus status = ConnectionStatus.Establishing) {
|
|
|
|
|
Endpoint = endpoint;
|
|
|
|
|
Status = status;
|
|
|
|
|
LastMessage = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds();
|
2020-08-02 02:50:01 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
2020-08-02 20:32:30 +02:00
|
|
|
|
|
|
|
|
|
public enum ConnectionStatus {
|
2020-08-05 03:21:04 +02:00
|
|
|
|
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
|
2020-08-02 20:32:30 +02:00
|
|
|
|
}
|
2020-08-02 02:50:01 +02:00
|
|
|
|
}
|