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 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(); 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); } }