0
0
Fork 0
mirror of https://github.com/Sanae6/SmoOnlineServer.git synced 2024-11-22 11:15:15 +00:00
This commit is contained in:
Sanae 2022-04-26 23:38:25 -06:00
parent 6444675fbb
commit cad2c5b9c8

View file

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