초기커밋
This commit is contained in:
@@ -0,0 +1,93 @@
|
||||
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.StopBuffReq), typeof(StopBuffPacketHandler), typeof(GameLoginListener))]
|
||||
public class StopBuffPacketHandler : PacketRecvHandler
|
||||
{
|
||||
public static bool send_S2C_ACK_STOP_BUFF(Player player, Result result)
|
||||
{
|
||||
var ack_packet = new ClientToGame();
|
||||
ack_packet.Response = new ClientToGameRes();
|
||||
|
||||
ack_packet.Response.ErrorCode = result.ErrorCode;
|
||||
ack_packet.Response.StopBuffRes = new StopBuffRes();
|
||||
|
||||
if (false == GameServerApp.getServerLogic().onSendPacket(player, ack_packet))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public override Task<Result> onProcessPacket(ISession entityWithSession, IMessage recvMessage)
|
||||
{
|
||||
var result = new Result();
|
||||
var err_msg = string.Empty;
|
||||
|
||||
var entity_player = entityWithSession as Player;
|
||||
ArgumentNullException.ThrowIfNull(entity_player, $"entity_player is null !!!");
|
||||
|
||||
var buff_action = entity_player.getEntityAction<BuffAction>();
|
||||
if (buff_action == null)
|
||||
{
|
||||
err_msg = $"Failed to get buff action : {nameof(BuffAction)}";
|
||||
result.setFail(ServerErrorCode.EntityActionNotFound, err_msg);
|
||||
Log.getLogger().error(err_msg);
|
||||
|
||||
send_S2C_ACK_STOP_BUFF(entity_player, result);
|
||||
return Task.FromResult(result);
|
||||
}
|
||||
|
||||
var game_msg = recvMessage as ClientToGame;
|
||||
if (game_msg == null)
|
||||
{
|
||||
err_msg = $"Failed to cast ClientToGame !!! : {nameof(ClientToGame.Request.StopBuffReq)}";
|
||||
result.setFail(ServerErrorCode.ClassTypeCastIsNull, err_msg);
|
||||
Log.getLogger().error(result.toBasicString());
|
||||
|
||||
send_S2C_ACK_STOP_BUFF(entity_player, result);
|
||||
return Task.FromResult(result);
|
||||
}
|
||||
|
||||
var request = game_msg.Request.StopBuffReq;
|
||||
|
||||
(result, var del_buff_attribute) = buff_action.DelBuffProcess((META_ID)request.BuffId);
|
||||
if (result.isFail())
|
||||
{
|
||||
err_msg = $"Failed to DelBuffProcess() !!! : {result.toBasicString()} - {entity_player.toBasicString()}";
|
||||
Log.getLogger().error(err_msg);
|
||||
send_S2C_ACK_STOP_BUFF(entity_player, result);
|
||||
return Task.FromResult(result);
|
||||
}
|
||||
|
||||
send_S2C_ACK_STOP_BUFF(entity_player, result);
|
||||
BuffNotifyHelper.send_S2C_NTF_DELETE_BUFF(entity_player, del_buff_attribute);
|
||||
|
||||
return Task.FromResult(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_STOP_BUFF(player, errorResult);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user