64 lines
1.9 KiB
C#
64 lines
1.9 KiB
C#
using Google.Protobuf;
|
|
using Google.Protobuf.WellKnownTypes;
|
|
using Nettention.Proud;
|
|
|
|
|
|
using ServerCore;
|
|
using ServerBase;
|
|
using ServerCommon;
|
|
using ServerCommon.BusinessLogDomain;
|
|
using MetaAssets;
|
|
|
|
|
|
namespace GameServer;
|
|
|
|
public class P2PPacketHandler : P2PPacketRecvHandler
|
|
{
|
|
public override async Task<Result> onProcessP2PPacket(ISession session, ByteArray receivedBytes)
|
|
{
|
|
var result = new Result();
|
|
|
|
try
|
|
{
|
|
var bytes = receivedBytes.data;
|
|
if(bytes is null) return result;
|
|
|
|
if (receivedBytes.Count < 4)
|
|
{
|
|
return result;
|
|
}
|
|
// var byte_json = receivedBytes.ToJson();
|
|
// Log.getLogger().debug($"p2p packet process packet json : {byte_json}");
|
|
|
|
byte[] headerBytes = bytes.Take(4).ToArray(); // 첫 4바이트만 추출
|
|
uint packet_id = BitConverter.ToUInt32(headerBytes, 0);
|
|
//Log.getLogger().debug($"Extracted header value: {packet_id}");
|
|
|
|
var player = session as Player;
|
|
if (player is null)
|
|
{
|
|
Log.getLogger().debug($"player is nulll: {session.toBasicString()}");
|
|
return result;
|
|
}
|
|
|
|
var p2p_data_action = player.getEntityAction<P2PDataAction>();
|
|
if (p2p_data_action is null)
|
|
{
|
|
Log.getLogger().debug($"p2p_data_action is null !!: {player.toBasicString()}");
|
|
return result;
|
|
}
|
|
|
|
await p2p_data_action.accumulateP2PData(packet_id, bytes);
|
|
|
|
//이부분은 고도화 될때 별도 처리
|
|
//패킷 단위로 로직 처리 분류 필요할 경우 고도화 처리 한다.
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
Log.getLogger().info($"p2p packet process error {ex.Message}");
|
|
return result;
|
|
}
|
|
|
|
return result;
|
|
}
|
|
} |