client data implementation

This commit is contained in:
rafi1212122
2023-06-04 16:04:43 +07:00
parent 9cf5e313a3
commit 2d1cee5753
3 changed files with 67 additions and 2 deletions

View File

@@ -1,4 +1,5 @@
using Common.Resources.Proto;
using Common.Database;
using Common.Resources.Proto;
namespace PemukulPaku.GameServer.Handlers
{
@@ -8,8 +9,24 @@ namespace PemukulPaku.GameServer.Handlers
public void Handle(Session session, Packet packet)
{
GetClientDataReq Data = packet.GetDecodedBody<GetClientDataReq>();
ClientDataScheme? clientData = Common.Database.ClientData.GetClientData(session.Player.User.Uid, Data.Type, Data.Id);
GetClientDataRsp Rsp = new() { retcode = GetClientDataRsp.Retcode.Succ, Id = Data.Id, Type = Data.Type };
session.Send(Packet.FromProto(new GetClientDataRsp() { retcode = GetClientDataRsp.Retcode.NotFound, Type = Data.Type, Id = Data.Id }, CmdId.GetClientDataRsp));
if (clientData is not null)
{
Rsp.ClientDataLists.Add(new()
{
Id = clientData.ClientDataId,
Type = clientData.Type,
Data = clientData.Data
});
}
else
{
Rsp.retcode = GetClientDataRsp.Retcode.NotFound;
}
session.Send(Packet.FromProto(Rsp, CmdId.GetClientDataRsp));
}
}
}

View File

@@ -0,0 +1,17 @@
using Common.Database;
using Common.Resources.Proto;
namespace PemukulPaku.GameServer.Handlers
{
[PacketCmdId(CmdId.SetClientDataReq)]
internal class SetClientDataReqHandler : IPacketHandler
{
public void Handle(Session session, Packet packet)
{
SetClientDataReq Data = packet.GetDecodedBody<SetClientDataReq>();
Common.Database.ClientData.SetClientData(session.Player.User.Uid, Data.ClientData.Type, Data.ClientData.Id, Data.ClientData.Data);
session.Send(Packet.FromProto(new SetClientDataRsp() { retcode = SetClientDataRsp.Retcode.Succ, Id = Data.ClientData.Id, Type = Data.ClientData.Type }, CmdId.SetClientDataRsp));
}
}
}