feat : 에코 서버 / 클라이언트 기능 추가 작업
This commit is contained in:
@@ -1,5 +1,8 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Net;
|
||||
using System.Net.Sockets;
|
||||
using System.Threading;
|
||||
using LiteNetLib;
|
||||
using LiteNetLib.Utils;
|
||||
using Serilog;
|
||||
@@ -122,6 +125,13 @@ public abstract class ServerBase : INetEventListener
|
||||
{
|
||||
(ushort type, ushort size, byte[] payload) = PacketSerializer.Deserialize(data);
|
||||
|
||||
// 0이라면 에코 서버 테스트용 따로 처리
|
||||
if (type == 0)
|
||||
{
|
||||
HandleEcho(peer, payload);
|
||||
return;
|
||||
}
|
||||
|
||||
// Auth 패킷은 베이스에서 처리 (raw 8-byte long, protobuf 불필요)
|
||||
if (type == (ushort)PacketType.Auth)
|
||||
{
|
||||
@@ -167,16 +177,33 @@ public abstract class ServerBase : INetEventListener
|
||||
}
|
||||
}
|
||||
|
||||
// Echo 서버 테스트
|
||||
|
||||
private void HandleEcho(NetPeer peer, byte[] payload)
|
||||
{
|
||||
// if (payload.Length < sizeof(long))
|
||||
// {
|
||||
// Log.Warning("[Server] Echo 페이로드 크기 오류 PeerId={Id}", peer.Id);
|
||||
// peer.Disconnect();
|
||||
// return;
|
||||
// }
|
||||
|
||||
// 세션에 넣지는 않는다.
|
||||
NetDataReader reader = new NetDataReader(payload);
|
||||
Log.Debug("[Echo] : addr={Addr}, str={Str}", peer.Address, reader.GetString());
|
||||
SendTo(peer, payload);
|
||||
}
|
||||
|
||||
// ─── Auth 처리 (내부) ────────────────────────────────────────────────
|
||||
|
||||
private void HandleAuth(NetPeer peer, byte[] payload)
|
||||
{
|
||||
if (payload.Length < sizeof(long))
|
||||
{
|
||||
Log.Warning("[Server] Auth 페이로드 크기 오류 PeerId={Id}", peer.Id);
|
||||
peer.Disconnect();
|
||||
return;
|
||||
}
|
||||
// if (payload.Length < sizeof(long))
|
||||
// {
|
||||
// Log.Warning("[Server] Auth 페이로드 크기 오류 PeerId={Id}", peer.Id);
|
||||
// peer.Disconnect();
|
||||
// return;
|
||||
// }
|
||||
|
||||
long hashKey = BitConverter.ToInt64(payload, 0);
|
||||
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
namespace ServerLib.Service;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace ServerLib.Service;
|
||||
|
||||
public class SessionManager
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user