0
0
Fork 0
mirror of https://github.com/Sanae6/SmoOnlineServer.git synced 2024-11-25 04:35:18 +00:00

Hopium that this fix works

This commit is contained in:
Sanae 2022-02-12 17:37:03 -06:00
parent 69ff9bb47d
commit 6d257ba04c

View file

@ -155,10 +155,10 @@ public class Server {
}; };
MemoryMarshal.Write(tempBuffer.Memory.Span[Constants.HeaderSize..], ref connectPacket); MemoryMarshal.Write(tempBuffer.Memory.Span[Constants.HeaderSize..], ref connectPacket);
await client.Send(tempBuffer.Memory, null); await client.Send(tempBuffer.Memory, null);
if (other.CurrentCostume is {} costumePacket) { if (other.CurrentCostume.HasValue) {
connectHeader.Type = PacketType.Costume; connectHeader.Type = PacketType.Costume;
MemoryMarshal.Write(tempBuffer.Memory.Span, ref connectHeader); MemoryMarshal.Write(tempBuffer.Memory.Span, ref connectHeader);
costumePacket.Serialize(tempBuffer.Memory.Span[Constants.HeaderSize..]); other.CurrentCostume.Value.Serialize(tempBuffer.Memory.Span[Constants.HeaderSize..]);
await client.Send(tempBuffer.Memory, null); await client.Send(tempBuffer.Memory, null);
} }
tempBuffer.Dispose(); tempBuffer.Dispose();
@ -167,11 +167,12 @@ public class Server {
Logger.Info($"Client {socket.RemoteEndPoint} ({client.Id}) connected."); Logger.Info($"Client {socket.RemoteEndPoint} ({client.Id}) connected.");
} }
// todo support variable length packets if they show up
// Logger.Warn($"broadcasting {header.Type} from {client.Id}");
if (header.Type == PacketType.Costume) { if (header.Type == PacketType.Costume) {
client.CurrentCostume ??= new CostumePacket(); CostumePacket costumePacket = new CostumePacket {
client.CurrentCostume.Value.Deserialize(memory.Memory.Span[Constants.HeaderSize..]); BodyName = ""
};
costumePacket.Deserialize(memory.Memory.Span[Constants.HeaderSize..]);
client.CurrentCostume = costumePacket;
} }
await Broadcast(memory, client); await Broadcast(memory, client);
} }