65 lines
2.8 KiB
C#
65 lines
2.8 KiB
C#
using Google.Protobuf;
|
|
using Google.Protobuf.WellKnownTypes;
|
|
|
|
|
|
using ServerCore;
|
|
using ServerBase;
|
|
using ServerCommon;
|
|
using ServerCommon.BusinessLogDomain;
|
|
using MetaAssets;
|
|
|
|
|
|
|
|
namespace GameServer.PacketHandler;
|
|
|
|
[PacketHandler("allgameserver", typeof(ServerMessage.Types.GS2GS_NTF_ADD_BUILDING_RENTAL_HISTORY), typeof(NtfAddBuildingRentalHistoryMQPacketHandler), typeof(RabbitMQ4Game))]
|
|
internal class NtfAddBuildingRentalHistoryMQPacketHandler : PacketRecvHandler
|
|
{
|
|
public override async Task<Result> onProcessPacket(ISession session, IMessage recvMessage)
|
|
{
|
|
var result = new Result();
|
|
var err_msg = string.Empty;
|
|
|
|
var server_logic = GameServerApp.getServerLogic();
|
|
ArgumentNullException.ThrowIfNull(server_logic, $"server_logic is null !!!");
|
|
|
|
var message = recvMessage as ServerMessage;
|
|
ArgumentNullException.ThrowIfNull(message, $"message is null !!!");
|
|
|
|
var ntf_add_building_rental_history = message. NtfAddBuildingRentalHistory;
|
|
ArgumentNullException.ThrowIfNull(ntf_add_building_rental_history, $"ntf_add_building_rental_history is null !!!");
|
|
|
|
if (ntf_add_building_rental_history.ExceptServerName == server_logic.getServerName())
|
|
return result;
|
|
|
|
Log.getLogger().info($"MQ - NtfAddBuildingRentalHistory");
|
|
|
|
if (!server_logic.getBuildingManager().tryGetBuilding(ntf_add_building_rental_history.BuildingMetaId, out var building))
|
|
{
|
|
err_msg = $"Failed to tryGetBuilding() !!! : buildingMetaId:{ntf_add_building_rental_history.BuildingMetaId}";
|
|
result.setFail(ServerErrorCode.BuildingNotFound, err_msg);
|
|
Log.getLogger().error(result.toBasicString());
|
|
|
|
return result;
|
|
}
|
|
|
|
var building_rental_history_agent_action = building.getEntityAction<BuildingRentalHistoryAgentAction>();
|
|
NullReferenceCheckHelper.throwIfNull(building_rental_history_agent_action, () => $"building_rental_history_agent_action is null !!!");
|
|
|
|
(result, var building_rental_history, _) = await BuildingRentalHistoryHelper.tryMakeBuildingRentalHistory(building, ntf_add_building_rental_history.BuildingMetaId, ntf_add_building_rental_history.Floor, ntf_add_building_rental_history.RenteeUserGuid, ntf_add_building_rental_history.RentalTime.ToDateTime(), ntf_add_building_rental_history.RentalPeriod);
|
|
if (result.isFail())
|
|
{
|
|
err_msg = $"Failed to tryMakeBuildingRentalHistory() !!! : {result.toBasicString()}";
|
|
Log.getLogger().error(err_msg);
|
|
|
|
return result;
|
|
}
|
|
NullReferenceCheckHelper.throwIfNull(building_rental_history, () => $"building_rental_history is null !!!");
|
|
|
|
// Memory
|
|
building_rental_history_agent_action.addBuildingRentalHistory(building_rental_history);
|
|
|
|
return result;
|
|
}
|
|
}
|