0
0
Fork 0
mirror of https://github.com/Sanae6/SmoOnlineServer.git synced 2024-11-26 05:05:24 +00:00

Absurd logging

This commit is contained in:
Sanae 2022-04-27 14:02:26 -06:00
parent 6288f8ae49
commit a775e593c3
2 changed files with 4 additions and 6 deletions

View file

@ -38,6 +38,8 @@ public class Client : IDisposable {
IMemoryOwner<byte> memory = MemoryPool<byte>.Shared.RentZero(Constants.HeaderSize + packet.Size); IMemoryOwner<byte> memory = MemoryPool<byte>.Shared.RentZero(Constants.HeaderSize + packet.Size);
PacketAttribute packetAttribute = Constants.PacketMap[typeof(T)]; PacketAttribute packetAttribute = Constants.PacketMap[typeof(T)];
if (packetAttribute.Type is not PacketType.Cap and not PacketType.Player)
Logger.Info($"Pre-header {packetAttribute.Type} ({(short)packetAttribute.Type}) - {typeof(T)}");
PacketHeader header = new PacketHeader { PacketHeader header = new PacketHeader {
Id = sender?.Id ?? Id, Id = sender?.Id ?? Id,
Type = packetAttribute.Type, Type = packetAttribute.Type,
@ -53,7 +55,7 @@ public class Client : IDisposable {
memory.Dispose(); memory.Dispose();
} }
public async Task Send(Memory<byte> data, Client? sender, PacketType? partTime = null) { public async Task Send(Memory<byte> data, Client? sender) {
PacketHeader header = new PacketHeader(); PacketHeader header = new PacketHeader();
header.Deserialize(data.Span); header.Deserialize(data.Span);
if (!Connected && header.Type is not PacketType.Connect) { if (!Connected && header.Type is not PacketType.Connect) {
@ -61,10 +63,6 @@ public class Client : IDisposable {
return; return;
} }
if (header.Type is not PacketType.Cap and not PacketType.Player) {
Logger.Info($"About to receive {header.Type} + ({(short)header.Type}), {partTime} ({(short?) partTime}) {new StackTrace().ToString()}");
}
await Socket!.SendAsync(data[..(Constants.HeaderSize + header.PacketSize)], SocketFlags.None); await Socket!.SendAsync(data[..(Constants.HeaderSize + header.PacketSize)], SocketFlags.None);
} }

View file

@ -67,7 +67,7 @@ public class Server {
// broadcast packets to all clients // broadcast packets to all clients
public delegate void PacketReplacer<in T>(Client from, Client to, T value); // replacer must send public delegate void PacketReplacer<in T>(Client from, Client to, T value); // replacer must send
public async Task BroadcastReplace<T>(T packet, Client sender, PacketReplacer<T> packetReplacer) where T : struct, IPacket { public void BroadcastReplace<T>(T packet, Client sender, PacketReplacer<T> packetReplacer) where T : struct, IPacket {
foreach (Client client in Clients.Where(client => sender.Id != client.Id)) packetReplacer(sender, client, packet); foreach (Client client in Clients.Where(client => sender.Id != client.Id)) packetReplacer(sender, client, packet);
} }