add protocol

This commit is contained in:
Le Duc Anh
2025-12-16 19:35:42 +07:00
parent f99c516cdb
commit 84e32e56b3
3 changed files with 71 additions and 1 deletions
@@ -166,7 +166,19 @@ namespace CSNetwork.Protocols
private static bool ValidateProtocol(uint type, uint size)
{
var stub = _protocolMap.GetValueOrDefault(type);
return stub != null && size <= MaxProtocolSize;
if (stub == null)
{
_logger.Warning($"ValidateProtocol: Protocol type {type} not found. Returning false.");
return false;
}
if (size > MaxProtocolSize)
{
_logger.Warning($"ValidateProtocol: Protocol type {type} size {size} is greater than MaxProtocolSize {MaxProtocolSize}. Returning false.");
return false;
}
return true;
}
private const int MaxProtocolSize = 16 * 1024 * 1024; // 16MB max size
@@ -0,0 +1,56 @@
using System;
using System.Collections.Generic;
namespace CSNetwork.Protocols
{
public class getcustomdata_re : Protocol
{
public int Result { get; set; }
public int Roleid { get; set; }
public int Localsid { get; set; }
public Octets UiConfig { get; set; }
public int retcode { get; set; }
public int roleid { get; set; }
public uint localsid { get; set; }
public uint cus_roleid { get; set; }
public Octets customdata {get; set;}
public getcustomdata_re() : base(ProtocolType.PROTOCOL_GETCUSTOMDATA_RE)
{
customdata = new Octets();
}
public override Protocol Clone() => new getcustomdata_re
{
retcode = retcode,
roleid = roleid,
localsid = localsid,
cus_roleid = cus_roleid,
customdata = customdata
};
public override void Marshal(OctetsStream os)
{
os.Write(retcode);
os.Write(roleid);
os.Write(localsid);
os.Write(cus_roleid);
os.Write(customdata);
}
public override void Unmarshal(OctetsStream os)
{
retcode = os.ReadInt32();
roleid = os.ReadInt32();
localsid = os.ReadUInt32();
cus_roleid = os.ReadUInt32();
customdata = os.ReadOctets();
}
public override int PriorPolicy() => 1;
public override bool SizePolicy(int size) => size <= 4096;
}
}
@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 6fa7e46f896407f499da351c8772b6d2