0
0
Fork 0
mirror of https://github.com/Sanae6/SmoOnlineServer.git synced 2024-11-05 03:05:04 +00:00
SmoOnlineServer/Server/Client.cs
2022-02-08 16:46:12 -06:00

28 lines
No EOL
956 B
C#

using System.Buffers;
using System.Net.Sockets;
using Shared.Packet.Packets;
namespace Server;
public class Client : IDisposable {
public Socket? Socket;
public bool Connected => Socket?.Connected ?? false;
public Guid Id;
public CostumePacket CurrentCostume = new CostumePacket {
BodyName = "",
CapName = ""
};
public readonly Dictionary<string, object> Metadata = new Dictionary<string, object>(); // can be used to store any information about a player
public async Task Send(Memory<byte> data) {
if (!Connected) return;
await Socket!.SendAsync(data, SocketFlags.None);
}
public void Dispose() {
Socket?.Disconnect(false);
}
public static bool operator ==(Client? left, Client? right) => left is { } leftClient && right is { } rightClient && leftClient.Id == rightClient.Id;
public static bool operator !=(Client? left, Client? right) => !(left == right);
}