0
0
Fork 0
mirror of https://github.com/Sanae6/SmoOnlineServer.git synced 2024-11-05 11:15:04 +00:00
SmoOnlineServer/Server/Client.cs

28 lines
934 B
C#
Raw Normal View History

2021-11-29 04:04:34 +00:00
using System.Buffers;
using System.Net.Sockets;
2022-02-08 22:46:12 +00:00
using Shared.Packet.Packets;
2021-11-29 04:04:34 +00:00
namespace Server;
public class Client : IDisposable {
public Socket? Socket;
2022-02-09 21:56:57 +00:00
public bool Connected = false;
2021-11-29 04:04:34 +00:00
public Guid Id;
2022-02-08 22:46:12 +00:00
public CostumePacket CurrentCostume = new CostumePacket {
BodyName = "",
CapName = ""
};
2021-11-29 04:04:34 +00:00
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);
}