2022-02-10 01:44:50 +00:00
|
|
|
|
using System.Net.Sockets;
|
2022-02-08 22:46:12 +00:00
|
|
|
|
using Shared.Packet.Packets;
|
2021-11-29 04:04:34 +00:00
|
|
|
|
|
2022-02-10 01:44:50 +00:00
|
|
|
|
namespace Server;
|
2021-11-29 04:04:34 +00:00
|
|
|
|
|
|
|
|
|
public class Client : IDisposable {
|
2022-02-10 01:44:50 +00:00
|
|
|
|
public readonly Dictionary<string, object> Metadata = new Dictionary<string, object>(); // can be used to store any information about a player
|
2022-02-09 21:56:57 +00:00
|
|
|
|
public bool Connected = false;
|
2022-02-10 01:44:50 +00:00
|
|
|
|
|
2022-02-08 22:46:12 +00:00
|
|
|
|
public CostumePacket CurrentCostume = new CostumePacket {
|
|
|
|
|
BodyName = "",
|
|
|
|
|
CapName = ""
|
|
|
|
|
};
|
2022-02-10 01:44:50 +00:00
|
|
|
|
|
|
|
|
|
public Guid Id;
|
|
|
|
|
public Socket? Socket;
|
|
|
|
|
|
|
|
|
|
public void Dispose() {
|
|
|
|
|
Socket?.Disconnect(false);
|
|
|
|
|
}
|
2021-11-29 04:04:34 +00:00
|
|
|
|
|
|
|
|
|
public async Task Send(Memory<byte> data) {
|
|
|
|
|
if (!Connected) return;
|
|
|
|
|
await Socket!.SendAsync(data, SocketFlags.None);
|
|
|
|
|
}
|
|
|
|
|
|
2022-02-10 01:44:50 +00:00
|
|
|
|
public static bool operator ==(Client? left, Client? right) {
|
|
|
|
|
return left is { } leftClient && right is { } rightClient && leftClient.Id == rightClient.Id;
|
2021-11-29 04:04:34 +00:00
|
|
|
|
}
|
|
|
|
|
|
2022-02-10 01:44:50 +00:00
|
|
|
|
public static bool operator !=(Client? left, Client? right) {
|
|
|
|
|
return !(left == right);
|
|
|
|
|
}
|
2021-11-29 04:04:34 +00:00
|
|
|
|
}
|