name in first arg, second seq for push
This commit is contained in:
parent
b63fab2887
commit
09140220a1
|
@ -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)
|
||||||
|
|
Loading…
Reference in New Issue