Files
hjha-server/GameFix/Common/Card/CardMessagePackFormatter.cs
xiaoou e9616125ce feat: initial commit - HJHA game server full source
6 major server modules (PdkFriendServer/GlobalSever/ServerCore/GameModule/GameNetModule) +
game logic (GameFix/GameDAL/ServerData) +
network layer (NetWorkMessage) +
data layer (ObjectModel) +
utilities (MrWu/Core/Config/CloudAPI/dll) +
adapters (zyxAdapter/base)

.NET 8.0 C# solution, 16 projects, 958 source files
2026-07-07 12:02:15 +08:00

38 lines
960 B
C#

#if Server
using MessagePack;
using MessagePack.Formatters;
namespace GameFix.Poker
{
public class CardMessagePackFormatter : IMessagePackFormatter<Card>
{
ICardIdResolver mResolver;
public CardMessagePackFormatter(ICardIdResolver resolver)
{
mResolver = resolver;
}
public void Serialize(ref MessagePackWriter writer, Card value, MessagePackSerializerOptions options)
{
if (value == null)
{
writer.WriteNil();
return;
}
writer.WriteInt32(value.Id);
}
public Card Deserialize(ref MessagePackReader reader, MessagePackSerializerOptions options)
{
if (reader.TryReadNil())
{
return null;
}
return mResolver.GetById(reader.ReadInt32());
}
}
}
#endif