초기커밋
This commit is contained in:
@@ -0,0 +1,105 @@
|
||||
using Google.Protobuf;
|
||||
|
||||
|
||||
using ServerCore;
|
||||
using ServerBase;
|
||||
using ServerCommon;
|
||||
|
||||
|
||||
using static ClientToGameRes.Types;
|
||||
|
||||
|
||||
using META_ID = System.UInt32;
|
||||
|
||||
|
||||
namespace GameServer.PacketHandler;
|
||||
|
||||
[PacketHandler(typeof(ClientToGameReq), typeof(ClientToGameReq.Types.C2GS_REQ_BEACON_SHOP_GET_ITEM_INFOS), typeof(BeaconShopGetItemInfosPacketHandler), typeof(GameLoginListener))]
|
||||
public class BeaconShopGetItemInfosPacketHandler : PacketRecvHandler
|
||||
{
|
||||
public static bool send_S2C_ACK_BEACON_SHOP_GET_ITEM_INFOS(Player player, Result result, List<BeaconShopItem>? beaconShopItem = null, int dailyRegisterCount = 0, int numOfReceiptNotReceived = 0)
|
||||
{
|
||||
var ack_packet = new ClientToGame();
|
||||
ack_packet.Response = new ClientToGameRes();
|
||||
|
||||
ack_packet.Response.ErrorCode = result.ErrorCode;
|
||||
ack_packet.Response.AckBeaconShopGetItemInfos = new GS2C_ACK_BEACON_SHOP_GET_ITEM_INFOS();
|
||||
|
||||
if (result.isSuccess() && beaconShopItem != null)
|
||||
{
|
||||
ack_packet.Response.AckBeaconShopGetItemInfos.BeaconShopInfos.AddRange(beaconShopItem.Select<BeaconShopItem, BeaconShopInfo>(x => x.toBeaconShopData4Client()).ToList());
|
||||
ack_packet.Response.AckBeaconShopGetItemInfos.DailyRegisterCount = dailyRegisterCount;
|
||||
ack_packet.Response.AckBeaconShopGetItemInfos.NumOfReceiptNotReceived = numOfReceiptNotReceived;
|
||||
}
|
||||
|
||||
if (false == GameServerApp.getServerLogic().onSendPacket(player, ack_packet))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public override async Task<Result> onProcessPacket(ISession entityWithSession, IMessage recvMessage)
|
||||
{
|
||||
var result = new Result();
|
||||
var err_msg = string.Empty;
|
||||
|
||||
var entity_player = entityWithSession as Player;
|
||||
NullReferenceCheckHelper.throwIfNull(entity_player, () => $"entity_player is null !!!");
|
||||
|
||||
var beacon_shop_action = entity_player.getEntityAction<BeaconShopAction>();
|
||||
if (beacon_shop_action == null)
|
||||
{
|
||||
err_msg = $"Failed to get beacon shop action : {nameof(BeaconShopAction)}";
|
||||
result.setFail(ServerErrorCode.EntityActionNotFound, err_msg);
|
||||
Log.getLogger().error(err_msg);
|
||||
|
||||
send_S2C_ACK_BEACON_SHOP_GET_ITEM_INFOS(entity_player, result);
|
||||
return result;
|
||||
}
|
||||
|
||||
var game_msg = recvMessage as ClientToGame;
|
||||
if (game_msg == null)
|
||||
{
|
||||
err_msg = $"Failed to cast ClientToGame !!! : {nameof(ClientToGame.Request.ReqBeaconShopGetItemInfos)}";
|
||||
result.setFail(ServerErrorCode.ClassTypeCastIsNull, err_msg);
|
||||
Log.getLogger().error(result.toBasicString());
|
||||
|
||||
send_S2C_ACK_BEACON_SHOP_GET_ITEM_INFOS(entity_player, result);
|
||||
return result;
|
||||
}
|
||||
|
||||
var request = game_msg.Request.ReqBeaconShopGetItemInfos;
|
||||
|
||||
if (request.BeaconGuid == string.Empty && request.BeaconOwnerGuid == string.Empty)
|
||||
{
|
||||
err_msg = $"Invalid Request Argument !!! : BeaconGuid : {request.BeaconGuid}, BeaconOwnerGuid : {request.BeaconOwnerGuid}";
|
||||
result.setFail(ServerErrorCode.BeaconShopInvalidArgument, err_msg);
|
||||
Log.getLogger().error(result.toBasicString());
|
||||
|
||||
send_S2C_ACK_BEACON_SHOP_GET_ITEM_INFOS(entity_player, result);
|
||||
return result;
|
||||
}
|
||||
|
||||
result = await beacon_shop_action.BeaconShopGetItemInfos(request.BeaconGuid, request.BeaconOwnerGuid);
|
||||
if (result.isFail())
|
||||
{
|
||||
send_S2C_ACK_BEACON_SHOP_GET_ITEM_INFOS(entity_player, result);
|
||||
return result;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public override async Task onProcessPacketException(ISession entityWithSession, IMessage recvMessage
|
||||
, Result errorResult)
|
||||
{
|
||||
await Task.CompletedTask;
|
||||
|
||||
var player = entityWithSession as Player;
|
||||
NullReferenceCheckHelper.throwIfNull(player, () => $"player is null !!! - {entityWithSession.toBasicString()}");
|
||||
|
||||
send_S2C_ACK_BEACON_SHOP_GET_ITEM_INFOS(player, errorResult);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user