초기커밋
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);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
using ServerCore; using ServerBase;
|
||||
using BEACON_GUID = System.String;
|
||||
|
||||
namespace GameServer
|
||||
{
|
||||
public static class BeaconShopNotifyHelper
|
||||
{
|
||||
public static bool send_S2C_NTF_BEACON_SHOP_REFRESH(this Player player, BEACON_GUID beaconGuid)
|
||||
{
|
||||
var noti_packet = makeAckBeaconShopRefreshPacket(beaconGuid);
|
||||
|
||||
if (false == GameServerApp.getServerLogic().onSendPacket(player, noti_packet))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public static ClientToGame makeAckBeaconShopRefreshPacket(BEACON_GUID beaconGuid)
|
||||
{
|
||||
var noti_packet = new ClientToGame();
|
||||
noti_packet.Message = new();
|
||||
noti_packet.Message.NtfBeaconShopRefresh = new();
|
||||
|
||||
noti_packet.Message.NtfBeaconShopRefresh.BeaconGuid = beaconGuid;
|
||||
|
||||
return noti_packet;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,107 @@
|
||||
using Google.Protobuf;
|
||||
|
||||
|
||||
using ServerCore;
|
||||
using ServerBase;
|
||||
using ServerCommon;
|
||||
|
||||
|
||||
using static ClientToGameRes.Types;
|
||||
|
||||
|
||||
namespace GameServer.PacketHandler;
|
||||
|
||||
|
||||
[PacketHandler(typeof(ClientToGameReq), typeof(ClientToGameReq.Types.C2GS_REQ_BEACON_SHOP_PURCHASE_ITEM), typeof(BeaconShopPurchaseItemPacketHandler), typeof(GameLoginListener))]
|
||||
public class BeaconShopPurchaseItemPacketHandler : PacketRecvHandler
|
||||
{
|
||||
public static bool send_S2C_ACK_BEACON_SHOP_PURCHASE_ITEM(Player player, Result result, string itemGuid = "", string beaconGuid = "", int itemAmount = 0, CommonResult? commonResult = null)
|
||||
{
|
||||
var ack_packet = new ClientToGame();
|
||||
ack_packet.Response = new ClientToGameRes();
|
||||
|
||||
ack_packet.Response.ErrorCode = result.ErrorCode;
|
||||
ack_packet.Response.AckBeaconShopPurchaseItem = new GS2C_ACK_BEACON_SHOP_PURCHASE_ITEM();
|
||||
|
||||
if (result.isSuccess())
|
||||
{
|
||||
ack_packet.Response.AckBeaconShopPurchaseItem.ItemGuid = itemGuid;
|
||||
ack_packet.Response.AckBeaconShopPurchaseItem.BeaconGuid = beaconGuid;
|
||||
ack_packet.Response.AckBeaconShopPurchaseItem.ItemAmount = itemAmount;
|
||||
ack_packet.Response.AckBeaconShopPurchaseItem.CommonResult = commonResult;
|
||||
}
|
||||
|
||||
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_PURCHASE_ITEM(entity_player, result);
|
||||
return result;
|
||||
}
|
||||
|
||||
var game_msg = recvMessage as ClientToGame;
|
||||
if (game_msg == null)
|
||||
{
|
||||
err_msg = $"Failed to cast ClientToGame !!! : {nameof(ClientToGame.Request.ReqBeaconShopPurchaseItem)}";
|
||||
result.setFail(ServerErrorCode.ClassTypeCastIsNull, err_msg);
|
||||
Log.getLogger().error(result.toBasicString());
|
||||
|
||||
send_S2C_ACK_BEACON_SHOP_PURCHASE_ITEM(entity_player, result);
|
||||
return result;
|
||||
}
|
||||
|
||||
var request = game_msg.Request.ReqBeaconShopPurchaseItem;
|
||||
|
||||
if(request.ItemGuid == string.Empty ||
|
||||
request.BeaconGuid == string.Empty ||
|
||||
request.ItemAmount <= 0 ||
|
||||
request.BeaconOwnerGuid == string.Empty)
|
||||
{
|
||||
err_msg = $"Invalid Request Argument !!! : ItemGuid : {request.ItemGuid}, BeaconGuid : {request.BeaconGuid}, ItemAmount : {request.ItemAmount}";
|
||||
result.setFail(ServerErrorCode.BeaconShopInvalidArgument, err_msg);
|
||||
Log.getLogger().error(result.toBasicString());
|
||||
|
||||
send_S2C_ACK_BEACON_SHOP_PURCHASE_ITEM(entity_player, result);
|
||||
return result;
|
||||
}
|
||||
|
||||
result = await beacon_shop_action.BeaconShopPurchaseItem(request.ItemGuid, (UInt16)request.ItemAmount, request.BeaconGuid, request.BeaconOwnerGuid);
|
||||
if (result.isFail())
|
||||
{
|
||||
send_S2C_ACK_BEACON_SHOP_PURCHASE_ITEM(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_PURCHASE_ITEM(player, errorResult);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,103 @@
|
||||
using Google.Protobuf;
|
||||
|
||||
|
||||
using ServerCore;
|
||||
using ServerBase;
|
||||
using ServerCommon;
|
||||
|
||||
|
||||
using static ClientToGameReq.Types;
|
||||
using static ClientToGameRes.Types;
|
||||
|
||||
|
||||
namespace GameServer.PacketHandler;
|
||||
|
||||
|
||||
[PacketHandler(typeof(ClientToGameReq), typeof(ClientToGameReq.Types.C2GS_REQ_BEACON_SHOP_RECEIVE_PAYMENT_FOR_SALES), typeof(BeaconShopReceivePaymentForSalesPacketHandler), typeof(GameLoginListener))]
|
||||
public class BeaconShopReceivePaymentForSalesPacketHandler : PacketRecvHandler
|
||||
{
|
||||
public static bool send_S2C_ACK_BEACON_SHOP_RECEIVE_PAYMENT_FOR_SALES(Player player, Result result, string beaconGuid = "", CommonResult? commonResult = null)
|
||||
{
|
||||
var ack_packet = new ClientToGame();
|
||||
ack_packet.Response = new ClientToGameRes();
|
||||
|
||||
ack_packet.Response.ErrorCode = result.ErrorCode;
|
||||
ack_packet.Response.AckBeaconShopReceivePaymentForSales = new GS2C_ACK_BEACON_SHOP_RECEIVE_PAYMENT_FOR_SALES();
|
||||
|
||||
if (result.isSuccess())
|
||||
{
|
||||
ack_packet.Response.AckBeaconShopReceivePaymentForSales.BeaconGuid = beaconGuid;
|
||||
ack_packet.Response.AckBeaconShopReceivePaymentForSales.CommonResult = commonResult;
|
||||
}
|
||||
|
||||
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_RECEIVE_PAYMENT_FOR_SALES(entity_player, result);
|
||||
return result;
|
||||
}
|
||||
|
||||
var game_msg = recvMessage as ClientToGame;
|
||||
if (game_msg == null)
|
||||
{
|
||||
err_msg = $"Failed to cast ClientToGame !!! : {nameof(ClientToGame.Request.ReqBeaconShopReceivePaymentForSales)}";
|
||||
result.setFail(ServerErrorCode.ClassTypeCastIsNull, err_msg);
|
||||
Log.getLogger().error(result.toBasicString());
|
||||
|
||||
send_S2C_ACK_BEACON_SHOP_RECEIVE_PAYMENT_FOR_SALES(entity_player, result);
|
||||
return result;
|
||||
}
|
||||
|
||||
var request = game_msg.Request.ReqBeaconShopReceivePaymentForSales;
|
||||
|
||||
if (request.BeaconGuid == string.Empty)
|
||||
{
|
||||
err_msg = $"Invalid Request Argument !!! : BeaconGuid : {request.BeaconGuid}";
|
||||
result.setFail(ServerErrorCode.BeaconShopInvalidArgument, err_msg);
|
||||
Log.getLogger().error(result.toBasicString());
|
||||
|
||||
send_S2C_ACK_BEACON_SHOP_RECEIVE_PAYMENT_FOR_SALES(entity_player, result);
|
||||
return result;
|
||||
}
|
||||
|
||||
result = await beacon_shop_action.BeaconShopReceivePaymentForSales(request.BeaconGuid);
|
||||
if (result.isFail())
|
||||
{
|
||||
send_S2C_ACK_BEACON_SHOP_RECEIVE_PAYMENT_FOR_SALES(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_RECEIVE_PAYMENT_FOR_SALES(player, errorResult);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,116 @@
|
||||
using Google.Protobuf;
|
||||
using Google.Protobuf.WellKnownTypes;
|
||||
|
||||
|
||||
using ServerCore;
|
||||
using ServerBase;
|
||||
using ServerCommon;
|
||||
|
||||
|
||||
using static ClientToGameReq.Types;
|
||||
using static ClientToGameRes.Types;
|
||||
|
||||
|
||||
|
||||
|
||||
namespace GameServer.PacketHandler;
|
||||
|
||||
[PacketHandler(typeof(ClientToGameReq), typeof(ClientToGameReq.Types.C2GS_REQ_BEACON_SHOP_REGISTER_ITEM), typeof(BeaconShopRegisterItemPacketHandler), typeof(GameLoginListener))]
|
||||
public class BeaconShopRegisterItemPacketHandler : PacketRecvHandler
|
||||
{
|
||||
public static bool send_S2C_ACK_BEACON_SHOP_REGISTER_ITEM(Player player, Result result, BeaconShopItem? beaconShopItem, CommonResult? commonResult = null)
|
||||
{
|
||||
var ack_packet = new ClientToGame();
|
||||
ack_packet.Response = new ClientToGameRes();
|
||||
|
||||
ack_packet.Response.ErrorCode = result.ErrorCode;
|
||||
ack_packet.Response.AckBeaconShopRegisterItem = new GS2C_ACK_BEACON_SHOP_REGISTER_ITEM();
|
||||
|
||||
if (result.isSuccess() && beaconShopItem != null)
|
||||
{
|
||||
var beacon_shop_attribute = beaconShopItem.getEntityAttribute<BeaconShopItemAttribute>();
|
||||
NullReferenceCheckHelper.throwIfNull(beacon_shop_attribute, () => $"beacon_shop_attribute is null !!!");
|
||||
|
||||
ack_packet.Response.AckBeaconShopRegisterItem.ItemGuid = beacon_shop_attribute.ItemGuid;
|
||||
ack_packet.Response.AckBeaconShopRegisterItem.ItemMetaId = (int)beacon_shop_attribute.ItemMetaId;
|
||||
ack_packet.Response.AckBeaconShopRegisterItem.ItemAmount = beacon_shop_attribute.ItemStackCount;
|
||||
ack_packet.Response.AckBeaconShopRegisterItem.SellingPrice = beacon_shop_attribute.PriceForUnit;
|
||||
ack_packet.Response.AckBeaconShopRegisterItem.BeaconGuid = beacon_shop_attribute.BeaconGuid;
|
||||
ack_packet.Response.AckBeaconShopRegisterItem.SellingFinishTime = Timestamp.FromDateTime(beacon_shop_attribute.SellingFinishTime);
|
||||
ack_packet.Response.AckBeaconShopRegisterItem.CommonResult = commonResult;
|
||||
}
|
||||
|
||||
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_REGISTER_ITEM(entity_player, result, null);
|
||||
return result;
|
||||
}
|
||||
|
||||
var game_msg = recvMessage as ClientToGame;
|
||||
if (game_msg == null)
|
||||
{
|
||||
err_msg = $"Failed to cast ClientToGame !!! : {nameof(ClientToGame.Request.ReqBeaconShopRegisterItem)}";
|
||||
result.setFail(ServerErrorCode.ClassTypeCastIsNull, err_msg);
|
||||
Log.getLogger().error(result.toBasicString());
|
||||
|
||||
send_S2C_ACK_BEACON_SHOP_REGISTER_ITEM(entity_player, result, null);
|
||||
return result;
|
||||
}
|
||||
|
||||
var request = game_msg.Request.ReqBeaconShopRegisterItem;
|
||||
|
||||
if (request.ItemGuid == string.Empty ||
|
||||
request.BeaconGuid == string.Empty ||
|
||||
request.ItemAmount <= 0 ||
|
||||
request.SellingPrice <= 0)
|
||||
{
|
||||
err_msg = $"Invalid Request Argument !!! : ItemGuid : {request.ItemGuid}, BeaconGuid : {request.BeaconGuid}, ItemAmount : {request.ItemAmount}, SellingPrice : {request.SellingPrice}";
|
||||
result.setFail(ServerErrorCode.BeaconShopInvalidArgument, err_msg);
|
||||
Log.getLogger().error(result.toBasicString());
|
||||
|
||||
send_S2C_ACK_BEACON_SHOP_REGISTER_ITEM(entity_player, result, null);
|
||||
return result;
|
||||
}
|
||||
|
||||
result = await beacon_shop_action.tryRegisterItemToBeaconShop(request.ItemGuid, (UInt16)request.ItemAmount, request.SellingPrice, request.BeaconGuid);
|
||||
if (result.isFail())
|
||||
{
|
||||
send_S2C_ACK_BEACON_SHOP_REGISTER_ITEM(entity_player, result, null);
|
||||
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_REGISTER_ITEM(player, errorResult, null);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,103 @@
|
||||
using Google.Protobuf;
|
||||
using Google.Protobuf.WellKnownTypes;
|
||||
|
||||
using ServerCore;
|
||||
using ServerBase;
|
||||
using ServerCommon;
|
||||
|
||||
using static ClientToGameReq.Types;
|
||||
using static ClientToGameRes.Types;
|
||||
|
||||
|
||||
namespace GameServer.PacketHandler;
|
||||
|
||||
[PacketHandler(typeof(ClientToGameReq), typeof(ClientToGameReq.Types.C2GS_REQ_BEACON_SHOP_RETURN_ITEM), typeof(BeaconShopReturnItemPacketHandler), typeof(GameLoginListener))]
|
||||
public class BeaconShopReturnItemPacketHandler : PacketRecvHandler
|
||||
{
|
||||
public static bool send_S2C_ACK_BEACON_SHOP_RETURN_ITEM(Player player, Result result, string itemGuid = "", string beaconGuid = "", CommonResult? commonResult = null)
|
||||
{
|
||||
var ack_packet = new ClientToGame();
|
||||
ack_packet.Response = new ClientToGameRes();
|
||||
|
||||
ack_packet.Response.ErrorCode = result.ErrorCode;
|
||||
ack_packet.Response.AckBeaconShopReturnItem = new GS2C_ACK_BEACON_SHOP_RETURN_ITEM();
|
||||
|
||||
if (result.isSuccess())
|
||||
{
|
||||
ack_packet.Response.AckBeaconShopReturnItem.ItemGuid = itemGuid;
|
||||
ack_packet.Response.AckBeaconShopReturnItem.BeaconGuid = beaconGuid;
|
||||
ack_packet.Response.AckBeaconShopReturnItem.CommonResult = commonResult;
|
||||
}
|
||||
|
||||
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_RETURN_ITEM(entity_player, result);
|
||||
return result;
|
||||
}
|
||||
|
||||
var game_msg = recvMessage as ClientToGame;
|
||||
if (game_msg == null)
|
||||
{
|
||||
err_msg = $"Failed to cast ClientToGame !!! : {nameof(ClientToGame.Request.ReqBeaconShopReturnItem)}";
|
||||
result.setFail(ServerErrorCode.ClassTypeCastIsNull, err_msg);
|
||||
Log.getLogger().error(result.toBasicString());
|
||||
|
||||
send_S2C_ACK_BEACON_SHOP_RETURN_ITEM(entity_player, result);
|
||||
return result;
|
||||
}
|
||||
|
||||
var request = game_msg.Request.ReqBeaconShopReturnItem;
|
||||
|
||||
if (request.ItemGuid == string.Empty ||
|
||||
request.BeaconGuid == string.Empty)
|
||||
{
|
||||
err_msg = $"Invalid Request Argument !!! : ItemGuid : {request.ItemGuid}, BeaconGuid : {request.BeaconGuid}";
|
||||
result.setFail(ServerErrorCode.BeaconShopInvalidArgument, err_msg);
|
||||
Log.getLogger().error(result.toBasicString());
|
||||
|
||||
send_S2C_ACK_BEACON_SHOP_RETURN_ITEM(entity_player, result);
|
||||
return result;
|
||||
}
|
||||
|
||||
result = await beacon_shop_action.BeaconShopReturnItem(request.ItemGuid, request.BeaconGuid);
|
||||
if (result.isFail())
|
||||
{
|
||||
send_S2C_ACK_BEACON_SHOP_RETURN_ITEM(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_RETURN_ITEM(player, errorResult);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,105 @@
|
||||
using Google.Protobuf;
|
||||
using Google.Protobuf.WellKnownTypes;
|
||||
|
||||
|
||||
using ServerCore;
|
||||
using ServerBase;
|
||||
using ServerCommon;
|
||||
|
||||
|
||||
using static ClientToGameReq.Types;
|
||||
using static ClientToGameRes.Types;
|
||||
|
||||
|
||||
using META_ID = System.UInt32;
|
||||
|
||||
|
||||
namespace GameServer.PacketHandler;
|
||||
|
||||
[PacketHandler(typeof(ClientToGameReq), typeof(ClientToGameReq.Types.C2GS_REQ_BEACON_SHOP_SEARCH_ITEM), typeof(BeaconShopSearchItemPacketHandler), typeof(GameLoginListener))]
|
||||
public class BeaconShopSearchItemPacketHandler : PacketRecvHandler
|
||||
{
|
||||
public static bool send_S2C_ACK_BEACON_SHOP_SEARCH_ITEM(Player player, Result result, List<BeaconShopMongoDoc>? beaconShopMongoDocs)
|
||||
{
|
||||
var ack_packet = new ClientToGame();
|
||||
ack_packet.Response = new ClientToGameRes();
|
||||
|
||||
ack_packet.Response.ErrorCode = result.ErrorCode;
|
||||
ack_packet.Response.AckBeaconShopSearchItem = new GS2C_ACK_BEACON_SHOP_SEARCH_ITEM();
|
||||
|
||||
if (result.isSuccess() && beaconShopMongoDocs != null)
|
||||
{
|
||||
ack_packet.Response.AckBeaconShopSearchItem.BeaconShopItemBoardInfos.AddRange(beaconShopMongoDocs.Select<BeaconShopMongoDoc, BeaconShopItemBoardInfo>(x => x.toBeaconShopItemMongoDataClient()).ToList());
|
||||
}
|
||||
|
||||
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_SEARCH_ITEM(entity_player, result, null);
|
||||
return result;
|
||||
}
|
||||
|
||||
var game_msg = recvMessage as ClientToGame;
|
||||
if (game_msg == null)
|
||||
{
|
||||
err_msg = $"Failed to cast ClientToGame !!! : {nameof(ClientToGame.Request.ReqBeaconShopSearchItem)}";
|
||||
result.setFail(ServerErrorCode.ClassTypeCastIsNull, err_msg);
|
||||
Log.getLogger().error(result.toBasicString());
|
||||
|
||||
send_S2C_ACK_BEACON_SHOP_SEARCH_ITEM(entity_player, result, null);
|
||||
return result;
|
||||
}
|
||||
|
||||
var request = game_msg.Request.ReqBeaconShopSearchItem;
|
||||
|
||||
if (request.ItemMetaid == 0)
|
||||
{
|
||||
err_msg = $"Invalid Request Argument !!! : ItemMetaid : {request.ItemMetaid}";
|
||||
result.setFail(ServerErrorCode.BeaconShopInvalidArgument, err_msg);
|
||||
Log.getLogger().error(result.toBasicString());
|
||||
|
||||
send_S2C_ACK_BEACON_SHOP_SEARCH_ITEM(entity_player, result, null);
|
||||
return result;
|
||||
}
|
||||
|
||||
result = await beacon_shop_action.BeaconShopSearchItem((META_ID)request.ItemMetaid);
|
||||
if (result.isFail())
|
||||
{
|
||||
send_S2C_ACK_BEACON_SHOP_SEARCH_ITEM(entity_player, result, null);
|
||||
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_SEARCH_ITEM(player, errorResult, null);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,106 @@
|
||||
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_SOLD_RECORDS), typeof(BeaconShopSoldRecordInfoPacketHandler), typeof(GameLoginListener))]
|
||||
public class BeaconShopSoldRecordInfoPacketHandler : PacketRecvHandler
|
||||
{
|
||||
public static bool send_S2C_ACK_BEACON_SHOP_GET_SOLD_RECORDS(Player player, Result result, List<BeaconShopSoldRecord>? beaconShopSoldRecords, double totalGivenPrice = 0)
|
||||
{
|
||||
var ack_packet = new ClientToGame();
|
||||
ack_packet.Response = new ClientToGameRes();
|
||||
|
||||
ack_packet.Response.ErrorCode = result.ErrorCode;
|
||||
ack_packet.Response.AckBeaconShopGetSoldRecords = new GS2C_ACK_BEACON_SHOP_GET_SOLD_RECORDS();
|
||||
|
||||
if (result.isSuccess() && beaconShopSoldRecords != null)
|
||||
{
|
||||
ack_packet.Response.AckBeaconShopGetSoldRecords.BeaconShopSoldRecordInfos.AddRange(beaconShopSoldRecords.Select<BeaconShopSoldRecord, BeaconShopSoldRecordInfo>(x => x.toBeaconShopSoldRecordData4Client()).ToList());
|
||||
ack_packet.Response.AckBeaconShopGetSoldRecords.TotalGivenPrice = totalGivenPrice;
|
||||
}
|
||||
|
||||
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_SOLD_RECORDS(entity_player, result, null);
|
||||
return result;
|
||||
}
|
||||
|
||||
var game_msg = recvMessage as ClientToGame;
|
||||
if (game_msg == null)
|
||||
{
|
||||
err_msg = $"Failed to cast ClientToGame !!! : {nameof(ClientToGame.Request.ReqBeaconShopGetSoldRecords)}";
|
||||
result.setFail(ServerErrorCode.ClassTypeCastIsNull, err_msg);
|
||||
Log.getLogger().error(result.toBasicString());
|
||||
|
||||
send_S2C_ACK_BEACON_SHOP_GET_SOLD_RECORDS(entity_player, result, null);
|
||||
return result;
|
||||
}
|
||||
|
||||
var request = game_msg.Request.ReqBeaconShopGetSoldRecords;
|
||||
|
||||
if (request.BeaconGuid == string.Empty)
|
||||
{
|
||||
err_msg = $"Invalid Request Argument !!! : BeaconGuid : {request.BeaconGuid}";
|
||||
result.setFail(ServerErrorCode.BeaconShopInvalidArgument, err_msg);
|
||||
Log.getLogger().error(result.toBasicString());
|
||||
|
||||
send_S2C_ACK_BEACON_SHOP_GET_SOLD_RECORDS(entity_player, result, null);
|
||||
return result;
|
||||
}
|
||||
|
||||
result = await beacon_shop_action.BeaconShopGetSoldRecords(request.BeaconGuid);
|
||||
if (result.isFail())
|
||||
{
|
||||
send_S2C_ACK_BEACON_SHOP_GET_SOLD_RECORDS(entity_player, result, null);
|
||||
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_SOLD_RECORDS(player, errorResult, null);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user