초기커밋
This commit is contained in:
@@ -0,0 +1,81 @@
|
||||
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.GetChannelListReq), typeof(GetChannelListPacketHandler), typeof(GameLoginListener))]
|
||||
public class GetChannelListPacketHandler : PacketRecvHandler
|
||||
{
|
||||
public static bool send_S2C_ACK_GET_CHANNEL_LIST(Player player, Result result, List<GameChannel>? channel_list)
|
||||
{
|
||||
var err_msg = string.Empty;
|
||||
|
||||
var ack_packet = new ClientToGame();
|
||||
ack_packet.Response = new ClientToGameRes();
|
||||
|
||||
ack_packet.Response.ErrorCode = result.ErrorCode;
|
||||
ack_packet.Response.GetChannelListRes = new GetChannelListRes();
|
||||
|
||||
if(channel_list != null)
|
||||
{
|
||||
var client_ui_channel_list = channel_list.Select(x => new ChannelInfo() { Channel = x.channel, Trafficlevel = x.trafficlevel }).ToList();
|
||||
ack_packet.Response.GetChannelListRes.ChannelInfoList.AddRange(client_ui_channel_list);
|
||||
}
|
||||
|
||||
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;
|
||||
NullReferenceCheckHelper.throwIfNull(entity_player, () => "player is null !!!");
|
||||
var server_logic = GameServerApp.getServerLogic();
|
||||
|
||||
var channel_action = entity_player.getEntityAction<ChannelAction>();
|
||||
if (channel_action == null)
|
||||
{
|
||||
err_msg = $"Failed to get chat action : {nameof(ChannelAction)}";
|
||||
result.setFail(ServerErrorCode.EntityActionNotFound, err_msg);
|
||||
Log.getLogger().error(err_msg);
|
||||
|
||||
send_S2C_ACK_GET_CHANNEL_LIST(entity_player, result, null);
|
||||
return Task.FromResult(result);
|
||||
}
|
||||
|
||||
result = channel_action.tryGetChannelList();
|
||||
if (result.isFail())
|
||||
{
|
||||
send_S2C_ACK_GET_CHANNEL_LIST(entity_player, result, null);
|
||||
return Task.FromResult(result);
|
||||
}
|
||||
|
||||
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_GET_CHANNEL_LIST(player, errorResult, null);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user