This commit is contained in:
Sanae 2022-04-26 23:38:25 -06:00
parent 6444675fbb
commit cad2c5b9c8
1 changed files with 6 additions and 2 deletions

View File

@ -48,11 +48,15 @@ public class Client : IDisposable {
}
public async Task Send(Memory<byte> data, Client? sender) {
if (!Connected) {
// Server.Logger.Info($"Didn't send {MemoryMarshal.Read<PacketType>(data.Span[16..])} to {Id} because they weren't connected yet");
PacketType packetType = MemoryMarshal.Read<PacketType>(data.Span[16..]);
if (!Connected && packetType is not PacketType.Connect) {
Server.Logger.Error($"Didn't send {packetType} to {Id} because they weren't connected yet");
return;
}
if (packetType is not PacketType.Cap and not PacketType.Player)
Logger.Info($"About to receive {packetType}");
int packetSize = MemoryMarshal.Read<short>(data.Span[18..]);
await Socket!.SendAsync(data[..(Constants.HeaderSize + packetSize)], SocketFlags.None);
}