name in first arg, second seq for push

This commit is contained in:
Kyle Belanger 2023-10-13 21:23:16 -04:00
parent b63fab2887
commit 09140220a1
1 changed files with 6 additions and 5 deletions

View File

@ -12,7 +12,8 @@ namespace AscNet.GameServer
public readonly TcpClient client; public readonly TcpClient client;
public readonly Logger c; public readonly Logger c;
private long lastPacketTime = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds(); private long lastPacketTime = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds();
private ushort packetNo = 1; private int packetNo = 1;
private int packetNo2 = 1;
private readonly MessagePackSerializerOptions lz4Options = MessagePackSerializerOptions.Standard.WithCompression(MessagePackCompression.Lz4Block); private readonly MessagePackSerializerOptions lz4Options = MessagePackSerializerOptions.Standard.WithCompression(MessagePackCompression.Lz4Block);
public Session(string id, TcpClient tcpClient) public Session(string id, TcpClient tcpClient)
@ -113,11 +114,11 @@ namespace AscNet.GameServer
DisconnectProtocol(); DisconnectProtocol();
} }
public void SendPush<T>(T push) public void SendPush<T>(string name, T push)
{ {
Packet.Push packet = new() Packet.Push packet = new()
{ {
Name = typeof(T).Name, Name = name,
Content = MessagePackSerializer.Serialize(push) Content = MessagePackSerializer.Serialize(push)
}; };
Send(new Packet() Send(new Packet()
@ -140,12 +141,12 @@ namespace AscNet.GameServer
}; };
Send(new Packet() Send(new Packet()
{ {
No = packetNo, No = packetNo2,
Type = Packet.ContentType.Response, Type = Packet.ContentType.Response,
Content = MessagePackSerializer.Serialize(packet) Content = MessagePackSerializer.Serialize(packet)
}); });
c.Log(packet.Name + " " + JsonConvert.SerializeObject(response)); c.Log(packet.Name + " " + JsonConvert.SerializeObject(response));
packetNo++; packetNo2++;
} }
private void Send(Packet packet) private void Send(Packet packet)