mirror of
https://github.com/tiennm99/zfoo.git
synced 2026-05-21 02:25:13 +00:00
ref[protocol]: 重构protocol的CSharp的解析
This commit is contained in:
@@ -204,7 +204,7 @@ public class CutDownListSerializer implements ICutDownSerializer {
|
||||
builder.append(StringUtils.format("buffer.writePacketArray({}, {})", objectStr, objectProtocolField.getProtocolId())).append(LS);
|
||||
break;
|
||||
case CSharp:
|
||||
builder.append(StringUtils.format("buffer.WritePacketList<>({}, {});", objectStr, objectProtocolField.getProtocolId())).append(LS);
|
||||
builder.append(StringUtils.format("buffer.WritePacketList({}, {});", objectStr, objectProtocolField.getProtocolId())).append(LS);
|
||||
break;
|
||||
default:
|
||||
flag = false;
|
||||
|
||||
@@ -109,7 +109,7 @@ public class CutDownMapSerializer implements ICutDownSerializer {
|
||||
builder.append(StringUtils.format("buffer.writeIntPacketMap({}, {})", objectStr, ((ObjectProtocolField) valueRegistration).getProtocolId())).append(LS);
|
||||
return true;
|
||||
case CSharp:
|
||||
builder.append(StringUtils.format("buffer.WriteIntPacketMap<>({}, {});", objectStr, ((ObjectProtocolField) valueRegistration).getProtocolId())).append(LS);
|
||||
builder.append(StringUtils.format("buffer.WriteIntPacketMap({}, {});", objectStr, ((ObjectProtocolField) valueRegistration).getProtocolId())).append(LS);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -171,7 +171,7 @@ public class CutDownMapSerializer implements ICutDownSerializer {
|
||||
builder.append(StringUtils.format("buffer.writeLongPacketMap({}, {})", objectStr, ((ObjectProtocolField) valueRegistration).getProtocolId())).append(LS);
|
||||
return true;
|
||||
case CSharp:
|
||||
builder.append(StringUtils.format("buffer.WriteLongPacketMap<>({}, {});", objectStr, ((ObjectProtocolField) valueRegistration).getProtocolId())).append(LS);
|
||||
builder.append(StringUtils.format("buffer.WriteLongPacketMap({}, {});", objectStr, ((ObjectProtocolField) valueRegistration).getProtocolId())).append(LS);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -233,7 +233,7 @@ public class CutDownMapSerializer implements ICutDownSerializer {
|
||||
builder.append(StringUtils.format("buffer.writeStringPacketMap({}, {})", objectStr, ((ObjectProtocolField) valueRegistration).getProtocolId())).append(LS);
|
||||
return true;
|
||||
case CSharp:
|
||||
builder.append(StringUtils.format("buffer.WriteStringPacketMap<>({}, {});", objectStr, ((ObjectProtocolField) valueRegistration).getProtocolId())).append(LS);
|
||||
builder.append(StringUtils.format("buffer.WriteStringPacketMap({}, {});", objectStr, ((ObjectProtocolField) valueRegistration).getProtocolId())).append(LS);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -312,7 +312,7 @@ public class CutDownMapSerializer implements ICutDownSerializer {
|
||||
builder.append(StringUtils.format("var {} = buffer.readIntPacketMap({})", map, ((ObjectProtocolField) valueRegistration).getProtocolId())).append(LS);
|
||||
return map;
|
||||
case CSharp:
|
||||
builder.append(StringUtils.format("var {} = buffer.ReadIntPacket<{}>Map({});", map, EnhanceObjectProtocolSerializer.getProtocolClassSimpleName(protocolId), protocolId)).append(LS);
|
||||
builder.append(StringUtils.format("var {} = buffer.ReadIntPacketMap<{}>({});", map, EnhanceObjectProtocolSerializer.getProtocolClassSimpleName(protocolId), protocolId)).append(LS);
|
||||
return map;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -202,7 +202,7 @@ public class CutDownSetSerializer implements ICutDownSerializer {
|
||||
builder.append(StringUtils.format("buffer.writePacketArray({}, {})", objectStr, objectProtocolField.getProtocolId())).append(LS);
|
||||
break;
|
||||
case CSharp:
|
||||
builder.append(StringUtils.format("buffer.WritePacketSet<>({}, {});", objectStr, objectProtocolField.getProtocolId())).append(LS);
|
||||
builder.append(StringUtils.format("buffer.WritePacketSet({}, {});", objectStr, objectProtocolField.getProtocolId())).append(LS);
|
||||
break;
|
||||
default:
|
||||
flag = false;
|
||||
|
||||
@@ -60,7 +60,8 @@ namespace CsProtocol.Buffer
|
||||
{
|
||||
if (writeIndex > buffer.Length)
|
||||
{
|
||||
throw new Exception("writeIndex[" + writeIndex + "] out of bounds exception: readerIndex: " + readOffset +
|
||||
throw new Exception("writeIndex[" + writeIndex + "] out of bounds exception: readerIndex: " +
|
||||
readOffset +
|
||||
", writerIndex: " + writeOffset +
|
||||
"(expected: 0 <= readerIndex <= writerIndex <= capacity:" + buffer.Length);
|
||||
}
|
||||
@@ -564,7 +565,7 @@ namespace CsProtocol.Buffer
|
||||
WriteBool(!flag);
|
||||
return flag;
|
||||
}
|
||||
|
||||
|
||||
public void WriteBooleanArray(bool[] array)
|
||||
{
|
||||
if ((array == null) || (array.Length == 0))
|
||||
@@ -581,7 +582,7 @@ namespace CsProtocol.Buffer
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public bool[] ReadBooleanArray()
|
||||
{
|
||||
int size = ReadInt();
|
||||
@@ -593,6 +594,7 @@ namespace CsProtocol.Buffer
|
||||
array[index] = ReadBool();
|
||||
}
|
||||
}
|
||||
|
||||
return array;
|
||||
}
|
||||
|
||||
@@ -624,6 +626,7 @@ namespace CsProtocol.Buffer
|
||||
array[index] = ReadByte();
|
||||
}
|
||||
}
|
||||
|
||||
return array;
|
||||
}
|
||||
|
||||
@@ -643,7 +646,7 @@ namespace CsProtocol.Buffer
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public short[] ReadShortArray()
|
||||
{
|
||||
int size = ReadInt();
|
||||
@@ -655,9 +658,10 @@ namespace CsProtocol.Buffer
|
||||
array[index] = ReadShort();
|
||||
}
|
||||
}
|
||||
|
||||
return array;
|
||||
}
|
||||
|
||||
|
||||
public void WriteIntArray(int[] array)
|
||||
{
|
||||
if ((array == null) || (array.Length == 0))
|
||||
@@ -674,7 +678,7 @@ namespace CsProtocol.Buffer
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public int[] ReadIntArray()
|
||||
{
|
||||
int size = ReadInt();
|
||||
@@ -686,9 +690,10 @@ namespace CsProtocol.Buffer
|
||||
array[index] = ReadInt();
|
||||
}
|
||||
}
|
||||
|
||||
return array;
|
||||
}
|
||||
|
||||
|
||||
public void WriteLongArray(long[] array)
|
||||
{
|
||||
if ((array == null) || (array.Length == 0))
|
||||
@@ -705,7 +710,7 @@ namespace CsProtocol.Buffer
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public long[] ReadLongArray()
|
||||
{
|
||||
int size = ReadInt();
|
||||
@@ -717,9 +722,10 @@ namespace CsProtocol.Buffer
|
||||
array[index] = ReadLong();
|
||||
}
|
||||
}
|
||||
|
||||
return array;
|
||||
}
|
||||
|
||||
|
||||
public void WriteFloatArray(float[] array)
|
||||
{
|
||||
if ((array == null) || (array.Length == 0))
|
||||
@@ -736,7 +742,7 @@ namespace CsProtocol.Buffer
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public float[] ReadFloatArray()
|
||||
{
|
||||
int size = ReadInt();
|
||||
@@ -748,9 +754,10 @@ namespace CsProtocol.Buffer
|
||||
array[index] = ReadLong();
|
||||
}
|
||||
}
|
||||
|
||||
return array;
|
||||
}
|
||||
|
||||
|
||||
public void WriteDoubleArray(double[] array)
|
||||
{
|
||||
if ((array == null) || (array.Length == 0))
|
||||
@@ -767,7 +774,7 @@ namespace CsProtocol.Buffer
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public double[] ReadDoubleArray()
|
||||
{
|
||||
int size = ReadInt();
|
||||
@@ -779,9 +786,10 @@ namespace CsProtocol.Buffer
|
||||
array[index] = ReadLong();
|
||||
}
|
||||
}
|
||||
|
||||
return array;
|
||||
}
|
||||
|
||||
|
||||
public void WriteCharArray(char[] array)
|
||||
{
|
||||
if ((array == null) || (array.Length == 0))
|
||||
@@ -798,7 +806,7 @@ namespace CsProtocol.Buffer
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public char[] ReadCharArray()
|
||||
{
|
||||
int size = ReadInt();
|
||||
@@ -810,9 +818,10 @@ namespace CsProtocol.Buffer
|
||||
array[index] = ReadChar();
|
||||
}
|
||||
}
|
||||
|
||||
return array;
|
||||
}
|
||||
|
||||
|
||||
public void WriteStringArray(string[] array)
|
||||
{
|
||||
if ((array == null) || (array.Length == 0))
|
||||
@@ -829,7 +838,7 @@ namespace CsProtocol.Buffer
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public string[] ReadStringArray()
|
||||
{
|
||||
int size = ReadInt();
|
||||
@@ -841,9 +850,10 @@ namespace CsProtocol.Buffer
|
||||
array[index] = ReadString();
|
||||
}
|
||||
}
|
||||
|
||||
return array;
|
||||
}
|
||||
|
||||
|
||||
public void WritePacketArray<T>(T[] array, short protocolId)
|
||||
{
|
||||
if ((array == null) || (array.Length == 0))
|
||||
@@ -861,7 +871,7 @@ namespace CsProtocol.Buffer
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public T[] ReadPacketArray<T>(short protocolId)
|
||||
{
|
||||
int size = ReadInt();
|
||||
@@ -874,9 +884,10 @@ namespace CsProtocol.Buffer
|
||||
array[index] = (T) protocolRegistration.Read(this);
|
||||
}
|
||||
}
|
||||
|
||||
return array;
|
||||
}
|
||||
|
||||
|
||||
public void WriteBooleanList(List<bool> list)
|
||||
{
|
||||
if ((list == null) || (list.Count == 0))
|
||||
@@ -893,7 +904,7 @@ namespace CsProtocol.Buffer
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public List<bool> ReadBooleanList()
|
||||
{
|
||||
int size = ReadInt();
|
||||
@@ -905,9 +916,10 @@ namespace CsProtocol.Buffer
|
||||
list.Add(ReadBool());
|
||||
}
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
|
||||
public void WriteByteList(List<byte> list)
|
||||
{
|
||||
if ((list == null) || (list.Count == 0))
|
||||
@@ -924,7 +936,7 @@ namespace CsProtocol.Buffer
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public List<byte> ReadByteList()
|
||||
{
|
||||
int size = ReadInt();
|
||||
@@ -936,9 +948,10 @@ namespace CsProtocol.Buffer
|
||||
list.Add(ReadByte());
|
||||
}
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
|
||||
public void WriteShortList(List<short> list)
|
||||
{
|
||||
if ((list == null) || (list.Count == 0))
|
||||
@@ -955,7 +968,7 @@ namespace CsProtocol.Buffer
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public List<short> ReadShortList()
|
||||
{
|
||||
int size = ReadInt();
|
||||
@@ -967,9 +980,10 @@ namespace CsProtocol.Buffer
|
||||
list.Add(ReadShort());
|
||||
}
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
|
||||
public void WriteIntList(List<int> list)
|
||||
{
|
||||
if ((list == null) || (list.Count == 0))
|
||||
@@ -986,7 +1000,7 @@ namespace CsProtocol.Buffer
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public List<int> ReadIntList()
|
||||
{
|
||||
int size = ReadInt();
|
||||
@@ -998,6 +1012,7 @@ namespace CsProtocol.Buffer
|
||||
list.Add(ReadInt());
|
||||
}
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
@@ -1029,6 +1044,7 @@ namespace CsProtocol.Buffer
|
||||
list.Add(ReadLong());
|
||||
}
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
@@ -1048,7 +1064,7 @@ namespace CsProtocol.Buffer
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public List<float> ReadFloatList()
|
||||
{
|
||||
int size = ReadInt();
|
||||
@@ -1060,9 +1076,10 @@ namespace CsProtocol.Buffer
|
||||
list.Add(ReadFloat());
|
||||
}
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
|
||||
public void WriteDoubleList(List<double> list)
|
||||
{
|
||||
if ((list == null) || (list.Count == 0))
|
||||
@@ -1079,7 +1096,7 @@ namespace CsProtocol.Buffer
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public List<double> ReadDoubleList()
|
||||
{
|
||||
int size = ReadInt();
|
||||
@@ -1091,9 +1108,10 @@ namespace CsProtocol.Buffer
|
||||
list.Add(ReadDouble());
|
||||
}
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
|
||||
public void WriteCharList(List<char> list)
|
||||
{
|
||||
if ((list == null) || (list.Count == 0))
|
||||
@@ -1110,7 +1128,7 @@ namespace CsProtocol.Buffer
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public List<char> ReadCharList()
|
||||
{
|
||||
int size = ReadInt();
|
||||
@@ -1122,9 +1140,10 @@ namespace CsProtocol.Buffer
|
||||
list.Add(ReadChar());
|
||||
}
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
|
||||
public void WriteStringList(List<string> list)
|
||||
{
|
||||
if ((list == null) || (list.Count == 0))
|
||||
@@ -1141,7 +1160,7 @@ namespace CsProtocol.Buffer
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public List<string> ReadStringList()
|
||||
{
|
||||
int size = ReadInt();
|
||||
@@ -1153,9 +1172,10 @@ namespace CsProtocol.Buffer
|
||||
list.Add(ReadString());
|
||||
}
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
|
||||
public void WritePacketList<T>(List<T> list, short protocolId)
|
||||
{
|
||||
if ((list == null) || (list.Count == 0))
|
||||
@@ -1173,7 +1193,7 @@ namespace CsProtocol.Buffer
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public List<T> ReadPacketList<T>(short protocolId)
|
||||
{
|
||||
int size = ReadInt();
|
||||
@@ -1186,6 +1206,7 @@ namespace CsProtocol.Buffer
|
||||
list.Add((T) protocolRegistration.Read(this));
|
||||
}
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
@@ -1208,7 +1229,7 @@ namespace CsProtocol.Buffer
|
||||
public HashSet<bool> ReadBooleanSet()
|
||||
{
|
||||
int size = ReadInt();
|
||||
HashSet<bool> set = new HashSet<bool>(size);
|
||||
HashSet<bool> set = new HashSet<bool>();
|
||||
if (size > 0)
|
||||
{
|
||||
for (int index = 0; index < size; index++)
|
||||
@@ -1216,6 +1237,7 @@ namespace CsProtocol.Buffer
|
||||
set.Add(ReadBool());
|
||||
}
|
||||
}
|
||||
|
||||
return set;
|
||||
}
|
||||
|
||||
@@ -1238,7 +1260,7 @@ namespace CsProtocol.Buffer
|
||||
public HashSet<short> ReadShortSet()
|
||||
{
|
||||
int size = ReadInt();
|
||||
HashSet<short> set = new HashSet<short>(size);
|
||||
HashSet<short> set = new HashSet<short>();
|
||||
if (size > 0)
|
||||
{
|
||||
for (int index = 0; index < size; index++)
|
||||
@@ -1246,6 +1268,7 @@ namespace CsProtocol.Buffer
|
||||
set.Add(ReadShort());
|
||||
}
|
||||
}
|
||||
|
||||
return set;
|
||||
}
|
||||
|
||||
@@ -1268,7 +1291,7 @@ namespace CsProtocol.Buffer
|
||||
public HashSet<int> ReadIntSet()
|
||||
{
|
||||
int size = ReadInt();
|
||||
HashSet<int> set = new HashSet<int>(size);
|
||||
HashSet<int> set = new HashSet<int>();
|
||||
if (size > 0)
|
||||
{
|
||||
for (int index = 0; index < size; index++)
|
||||
@@ -1276,6 +1299,7 @@ namespace CsProtocol.Buffer
|
||||
set.Add(ReadInt());
|
||||
}
|
||||
}
|
||||
|
||||
return set;
|
||||
}
|
||||
|
||||
@@ -1298,7 +1322,7 @@ namespace CsProtocol.Buffer
|
||||
public HashSet<long> ReadLongSet()
|
||||
{
|
||||
int size = ReadInt();
|
||||
HashSet<long> set = new HashSet<long>(size);
|
||||
HashSet<long> set = new HashSet<long>();
|
||||
if (size > 0)
|
||||
{
|
||||
for (int index = 0; index < size; index++)
|
||||
@@ -1306,6 +1330,7 @@ namespace CsProtocol.Buffer
|
||||
set.Add(ReadLong());
|
||||
}
|
||||
}
|
||||
|
||||
return set;
|
||||
}
|
||||
|
||||
@@ -1328,7 +1353,7 @@ namespace CsProtocol.Buffer
|
||||
public HashSet<float> ReadFloatSet()
|
||||
{
|
||||
int size = ReadInt();
|
||||
HashSet<float> set = new HashSet<float>(size);
|
||||
HashSet<float> set = new HashSet<float>();
|
||||
if (size > 0)
|
||||
{
|
||||
for (int index = 0; index < size; index++)
|
||||
@@ -1336,6 +1361,7 @@ namespace CsProtocol.Buffer
|
||||
set.Add(ReadFloat());
|
||||
}
|
||||
}
|
||||
|
||||
return set;
|
||||
}
|
||||
|
||||
@@ -1358,7 +1384,7 @@ namespace CsProtocol.Buffer
|
||||
public HashSet<double> ReadDoubleSet()
|
||||
{
|
||||
int size = ReadInt();
|
||||
HashSet<double> set = new HashSet<double>(size);
|
||||
HashSet<double> set = new HashSet<double>();
|
||||
if (size > 0)
|
||||
{
|
||||
for (int index = 0; index < size; index++)
|
||||
@@ -1366,6 +1392,7 @@ namespace CsProtocol.Buffer
|
||||
set.Add(ReadDouble());
|
||||
}
|
||||
}
|
||||
|
||||
return set;
|
||||
}
|
||||
|
||||
@@ -1388,7 +1415,7 @@ namespace CsProtocol.Buffer
|
||||
public HashSet<char> ReadCharSet()
|
||||
{
|
||||
int size = ReadInt();
|
||||
HashSet<char> set = new HashSet<char>(size);
|
||||
HashSet<char> set = new HashSet<char>();
|
||||
if (size > 0)
|
||||
{
|
||||
for (int index = 0; index < size; index++)
|
||||
@@ -1396,6 +1423,7 @@ namespace CsProtocol.Buffer
|
||||
set.Add(ReadChar());
|
||||
}
|
||||
}
|
||||
|
||||
return set;
|
||||
}
|
||||
|
||||
@@ -1418,7 +1446,7 @@ namespace CsProtocol.Buffer
|
||||
public HashSet<string> ReadStringSet()
|
||||
{
|
||||
int size = ReadInt();
|
||||
HashSet<string> set = new HashSet<string>(size);
|
||||
HashSet<string> set = new HashSet<string>();
|
||||
if (size > 0)
|
||||
{
|
||||
for (int index = 0; index < size; index++)
|
||||
@@ -1426,6 +1454,7 @@ namespace CsProtocol.Buffer
|
||||
set.Add(ReadString());
|
||||
}
|
||||
}
|
||||
|
||||
return set;
|
||||
}
|
||||
|
||||
@@ -1449,7 +1478,7 @@ namespace CsProtocol.Buffer
|
||||
public HashSet<T> ReadPacketSet<T>(short protocolId)
|
||||
{
|
||||
int size = ReadInt();
|
||||
HashSet<T> set = new HashSet<T>(size);
|
||||
HashSet<T> set = new HashSet<T>();
|
||||
if (size > 0)
|
||||
{
|
||||
IProtocolRegistration protocolRegistration = ProtocolManager.GetProtocol(protocolId);
|
||||
@@ -1458,6 +1487,7 @@ namespace CsProtocol.Buffer
|
||||
set.Add((T) protocolRegistration.Read(this));
|
||||
}
|
||||
}
|
||||
|
||||
return set;
|
||||
}
|
||||
|
||||
@@ -1491,6 +1521,7 @@ namespace CsProtocol.Buffer
|
||||
map[key] = value;
|
||||
}
|
||||
}
|
||||
|
||||
return map;
|
||||
}
|
||||
|
||||
@@ -1524,6 +1555,7 @@ namespace CsProtocol.Buffer
|
||||
map[key] = value;
|
||||
}
|
||||
}
|
||||
|
||||
return map;
|
||||
}
|
||||
|
||||
@@ -1557,44 +1589,46 @@ namespace CsProtocol.Buffer
|
||||
map[key] = value;
|
||||
}
|
||||
}
|
||||
|
||||
return map;
|
||||
}
|
||||
|
||||
|
||||
public void WriteIntPacketMap<T>(Dictionary<int, T> map, short protocolId)
|
||||
{
|
||||
if ((map == null) || (map.Count == 0))
|
||||
{
|
||||
WriteInt(0);
|
||||
}
|
||||
else
|
||||
{
|
||||
IProtocolRegistration protocolRegistration = ProtocolManager.GetProtocol(protocolId);
|
||||
WriteInt(map.Count);
|
||||
foreach (var element in map)
|
||||
{
|
||||
WriteInt(element.Key);
|
||||
protocolRegistration.Write(this, (IPacket) element.Value);
|
||||
}
|
||||
}
|
||||
}
|
||||
public void WriteIntPacketMap<T>(Dictionary<int, T> map, short protocolId)
|
||||
{
|
||||
if ((map == null) || (map.Count == 0))
|
||||
{
|
||||
WriteInt(0);
|
||||
}
|
||||
else
|
||||
{
|
||||
IProtocolRegistration protocolRegistration = ProtocolManager.GetProtocol(protocolId);
|
||||
WriteInt(map.Count);
|
||||
foreach (var element in map)
|
||||
{
|
||||
WriteInt(element.Key);
|
||||
protocolRegistration.Write(this, (IPacket) element.Value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public Dictionary<int, T> ReadIntPacketMap<T>(short protocolId)
|
||||
{
|
||||
int size = ReadInt();
|
||||
Dictionary<int, T> map = new Dictionary<int, T>(size);
|
||||
if (size > 0)
|
||||
{
|
||||
IProtocolRegistration protocolRegistration = ProtocolManager.GetProtocol(protocolId);
|
||||
for (int index = 0; index < size; index++)
|
||||
{
|
||||
var key = ReadInt();
|
||||
var value = (T) protocolRegistration.Read(this);
|
||||
map[key] = value;
|
||||
}
|
||||
}
|
||||
return map;
|
||||
}
|
||||
public Dictionary<int, T> ReadIntPacketMap<T>(short protocolId)
|
||||
{
|
||||
int size = ReadInt();
|
||||
Dictionary<int, T> map = new Dictionary<int, T>(size);
|
||||
if (size > 0)
|
||||
{
|
||||
IProtocolRegistration protocolRegistration = ProtocolManager.GetProtocol(protocolId);
|
||||
for (int index = 0; index < size; index++)
|
||||
{
|
||||
var key = ReadInt();
|
||||
var value = (T) protocolRegistration.Read(this);
|
||||
map[key] = value;
|
||||
}
|
||||
}
|
||||
|
||||
return map;
|
||||
}
|
||||
|
||||
public void WriteLongIntMap(Dictionary<long, int> map)
|
||||
{
|
||||
@@ -1626,6 +1660,7 @@ namespace CsProtocol.Buffer
|
||||
map[key] = value;
|
||||
}
|
||||
}
|
||||
|
||||
return map;
|
||||
}
|
||||
|
||||
@@ -1659,6 +1694,7 @@ namespace CsProtocol.Buffer
|
||||
map[key] = value;
|
||||
}
|
||||
}
|
||||
|
||||
return map;
|
||||
}
|
||||
|
||||
@@ -1692,44 +1728,46 @@ namespace CsProtocol.Buffer
|
||||
map[key] = value;
|
||||
}
|
||||
}
|
||||
|
||||
return map;
|
||||
}
|
||||
|
||||
|
||||
public void WriteLongPacketMap<T>(Dictionary<long, T> map, short protocolId)
|
||||
{
|
||||
if ((map == null) || (map.Count == 0))
|
||||
{
|
||||
WriteInt(0);
|
||||
}
|
||||
else
|
||||
{
|
||||
IProtocolRegistration protocolRegistration = ProtocolManager.GetProtocol(protocolId);
|
||||
WriteInt(map.Count);
|
||||
foreach (var element in map)
|
||||
{
|
||||
WriteLong(element.Key);
|
||||
protocolRegistration.Write(this, (IPacket) element.Value);
|
||||
}
|
||||
}
|
||||
}
|
||||
public void WriteLongPacketMap<T>(Dictionary<long, T> map, short protocolId)
|
||||
{
|
||||
if ((map == null) || (map.Count == 0))
|
||||
{
|
||||
WriteInt(0);
|
||||
}
|
||||
else
|
||||
{
|
||||
IProtocolRegistration protocolRegistration = ProtocolManager.GetProtocol(protocolId);
|
||||
WriteInt(map.Count);
|
||||
foreach (var element in map)
|
||||
{
|
||||
WriteLong(element.Key);
|
||||
protocolRegistration.Write(this, (IPacket) element.Value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public Dictionary<long, T> ReadLongPacketMap<T>(short protocolId)
|
||||
{
|
||||
int size = ReadInt();
|
||||
Dictionary<long, T> map = new Dictionary<long, T>(size);
|
||||
if (size > 0)
|
||||
{
|
||||
IProtocolRegistration protocolRegistration = ProtocolManager.GetProtocol(protocolId);
|
||||
for (int index = 0; index < size; index++)
|
||||
{
|
||||
var key = ReadLong();
|
||||
var value = (T) protocolRegistration.Read(this);
|
||||
map[key] = value;
|
||||
}
|
||||
}
|
||||
return map;
|
||||
}
|
||||
public Dictionary<long, T> ReadLongPacketMap<T>(short protocolId)
|
||||
{
|
||||
int size = ReadInt();
|
||||
Dictionary<long, T> map = new Dictionary<long, T>(size);
|
||||
if (size > 0)
|
||||
{
|
||||
IProtocolRegistration protocolRegistration = ProtocolManager.GetProtocol(protocolId);
|
||||
for (int index = 0; index < size; index++)
|
||||
{
|
||||
var key = ReadLong();
|
||||
var value = (T) protocolRegistration.Read(this);
|
||||
map[key] = value;
|
||||
}
|
||||
}
|
||||
|
||||
return map;
|
||||
}
|
||||
|
||||
public void WriteStringIntMap(Dictionary<string, int> map)
|
||||
{
|
||||
@@ -1761,6 +1799,7 @@ namespace CsProtocol.Buffer
|
||||
map[key] = value;
|
||||
}
|
||||
}
|
||||
|
||||
return map;
|
||||
}
|
||||
|
||||
@@ -1794,6 +1833,7 @@ namespace CsProtocol.Buffer
|
||||
map[key] = value;
|
||||
}
|
||||
}
|
||||
|
||||
return map;
|
||||
}
|
||||
|
||||
@@ -1827,43 +1867,45 @@ namespace CsProtocol.Buffer
|
||||
map[key] = value;
|
||||
}
|
||||
}
|
||||
|
||||
return map;
|
||||
}
|
||||
|
||||
|
||||
public void WriteStringPacketMap<T>(Dictionary<string, T> map, short protocolId)
|
||||
{
|
||||
if ((map == null) || (map.Count == 0))
|
||||
{
|
||||
WriteInt(0);
|
||||
}
|
||||
else
|
||||
{
|
||||
IProtocolRegistration protocolRegistration = ProtocolManager.GetProtocol(protocolId);
|
||||
WriteInt(map.Count);
|
||||
foreach (var element in map)
|
||||
{
|
||||
WriteString(element.Key);
|
||||
protocolRegistration.Write(this, (IPacket) element.Value);
|
||||
}
|
||||
}
|
||||
}
|
||||
public void WriteStringPacketMap<T>(Dictionary<string, T> map, short protocolId)
|
||||
{
|
||||
if ((map == null) || (map.Count == 0))
|
||||
{
|
||||
WriteInt(0);
|
||||
}
|
||||
else
|
||||
{
|
||||
IProtocolRegistration protocolRegistration = ProtocolManager.GetProtocol(protocolId);
|
||||
WriteInt(map.Count);
|
||||
foreach (var element in map)
|
||||
{
|
||||
WriteString(element.Key);
|
||||
protocolRegistration.Write(this, (IPacket) element.Value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public Dictionary<string, T> ReadStringPacketMap<T>(short protocolId)
|
||||
{
|
||||
int size = ReadInt();
|
||||
Dictionary<string, T> map = new Dictionary<string, T>(size);
|
||||
if (size > 0)
|
||||
{
|
||||
IProtocolRegistration protocolRegistration = ProtocolManager.GetProtocol(protocolId);
|
||||
for (int index = 0; index < size; index++)
|
||||
{
|
||||
var key = ReadString();
|
||||
var value = (T) protocolRegistration.Read(this);
|
||||
map[key] = value;
|
||||
}
|
||||
}
|
||||
return map;
|
||||
}
|
||||
public Dictionary<string, T> ReadStringPacketMap<T>(short protocolId)
|
||||
{
|
||||
int size = ReadInt();
|
||||
Dictionary<string, T> map = new Dictionary<string, T>(size);
|
||||
if (size > 0)
|
||||
{
|
||||
IProtocolRegistration protocolRegistration = ProtocolManager.GetProtocol(protocolId);
|
||||
for (int index = 0; index < size; index++)
|
||||
{
|
||||
var key = ReadString();
|
||||
var value = (T) protocolRegistration.Read(this);
|
||||
map[key] = value;
|
||||
}
|
||||
}
|
||||
|
||||
return map;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
namespace CsProtocol.Buffer
|
||||
namespace CsProtocol.Buffer
|
||||
{
|
||||
public class BigEndianByteBuffer : ByteBuffer
|
||||
{
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,4 +1,4 @@
|
||||
namespace CsProtocol.Buffer
|
||||
namespace CsProtocol.Buffer
|
||||
{
|
||||
public interface IPacket
|
||||
{
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
namespace CsProtocol.Buffer
|
||||
namespace CsProtocol.Buffer
|
||||
{
|
||||
public interface IProtocolRegistration
|
||||
{
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -5,61 +5,44 @@ using CsProtocol.Buffer;
|
||||
namespace CsProtocol
|
||||
{
|
||||
// @author jaysunxiao
|
||||
// @version 1.0
|
||||
// @since 2021-02-07 17:18
|
||||
// @version 3.0
|
||||
public class NormalObject : IPacket
|
||||
{
|
||||
public byte a;
|
||||
public byte[] aaa;
|
||||
public short b;
|
||||
public short[] bbb;
|
||||
public int c;
|
||||
public int[] ccc;
|
||||
public long d;
|
||||
public long[] ddd;
|
||||
public float e;
|
||||
public float[] eee;
|
||||
public double f;
|
||||
public double[] fff;
|
||||
public bool g;
|
||||
public bool[] ggg;
|
||||
public char h;
|
||||
public char[] hhh;
|
||||
public string jj;
|
||||
public string[] jjj;
|
||||
public ObjectA kk;
|
||||
public ObjectA[] kkk;
|
||||
public List<int> l;
|
||||
public List<long> ll;
|
||||
public List<ObjectA> lll;
|
||||
public List<string> llll;
|
||||
public Dictionary<int, string> m;
|
||||
public Dictionary<int, ObjectA> mm;
|
||||
public HashSet<int> s;
|
||||
public HashSet<string> ssss;
|
||||
|
||||
public static NormalObject ValueOf(byte a, byte[] aaa, short b, short[] bbb, int c, int[] ccc, long d, long[] ddd, float e, float[] eee, double f, double[] fff, bool g, bool[] ggg, char h, char[] hhh, string jj, string[] jjj, ObjectA kk, ObjectA[] kkk, List<int> l, List<string> llll, Dictionary<int, string> m, Dictionary<int, ObjectA> mm, HashSet<int> s, HashSet<string> ssss)
|
||||
public static NormalObject ValueOf(byte a, byte[] aaa, short b, int c, long d, float e, double f, bool g, string jj, ObjectA kk, List<int> l, List<long> ll, List<ObjectA> lll, List<string> llll, Dictionary<int, string> m, Dictionary<int, ObjectA> mm, HashSet<int> s, HashSet<string> ssss)
|
||||
{
|
||||
var packet = new NormalObject();
|
||||
packet.a = a;
|
||||
packet.aaa = aaa;
|
||||
packet.b = b;
|
||||
packet.bbb = bbb;
|
||||
packet.c = c;
|
||||
packet.ccc = ccc;
|
||||
packet.d = d;
|
||||
packet.ddd = ddd;
|
||||
packet.e = e;
|
||||
packet.eee = eee;
|
||||
packet.f = f;
|
||||
packet.fff = fff;
|
||||
packet.g = g;
|
||||
packet.ggg = ggg;
|
||||
packet.h = h;
|
||||
packet.hhh = hhh;
|
||||
packet.jj = jj;
|
||||
packet.jjj = jjj;
|
||||
packet.kk = kk;
|
||||
packet.kkk = kkk;
|
||||
packet.l = l;
|
||||
packet.ll = ll;
|
||||
packet.lll = lll;
|
||||
packet.llll = llll;
|
||||
packet.m = m;
|
||||
packet.mm = mm;
|
||||
@@ -71,7 +54,7 @@ namespace CsProtocol
|
||||
|
||||
public short ProtocolId()
|
||||
{
|
||||
return 1161;
|
||||
return 101;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -80,250 +63,34 @@ namespace CsProtocol
|
||||
{
|
||||
public short ProtocolId()
|
||||
{
|
||||
return 1161;
|
||||
return 101;
|
||||
}
|
||||
|
||||
public void Write(ByteBuffer buffer, IPacket packet)
|
||||
{
|
||||
if (packet == null)
|
||||
if (buffer.WritePacketFlag(packet))
|
||||
{
|
||||
buffer.WriteBool(false);
|
||||
return;
|
||||
}
|
||||
buffer.WriteBool(true);
|
||||
NormalObject message = (NormalObject) packet;
|
||||
buffer.WriteByte(message.a);
|
||||
if ((message.aaa == null) || (message.aaa.Length == 0))
|
||||
{
|
||||
buffer.WriteInt(0);
|
||||
}
|
||||
else
|
||||
{
|
||||
buffer.WriteInt(message.aaa.Length);
|
||||
int length0 = message.aaa.Length;
|
||||
for (int i1 = 0; i1 < length0; i1++)
|
||||
{
|
||||
byte element2 = message.aaa[i1];
|
||||
buffer.WriteByte(element2);
|
||||
}
|
||||
}
|
||||
buffer.WriteByteArray(message.aaa);
|
||||
buffer.WriteShort(message.b);
|
||||
if ((message.bbb == null) || (message.bbb.Length == 0))
|
||||
{
|
||||
buffer.WriteInt(0);
|
||||
}
|
||||
else
|
||||
{
|
||||
buffer.WriteInt(message.bbb.Length);
|
||||
int length3 = message.bbb.Length;
|
||||
for (int i4 = 0; i4 < length3; i4++)
|
||||
{
|
||||
short element5 = message.bbb[i4];
|
||||
buffer.WriteShort(element5);
|
||||
}
|
||||
}
|
||||
buffer.WriteInt(message.c);
|
||||
if ((message.ccc == null) || (message.ccc.Length == 0))
|
||||
{
|
||||
buffer.WriteInt(0);
|
||||
}
|
||||
else
|
||||
{
|
||||
buffer.WriteInt(message.ccc.Length);
|
||||
int length6 = message.ccc.Length;
|
||||
for (int i7 = 0; i7 < length6; i7++)
|
||||
{
|
||||
int element8 = message.ccc[i7];
|
||||
buffer.WriteInt(element8);
|
||||
}
|
||||
}
|
||||
buffer.WriteLong(message.d);
|
||||
if ((message.ddd == null) || (message.ddd.Length == 0))
|
||||
{
|
||||
buffer.WriteInt(0);
|
||||
}
|
||||
else
|
||||
{
|
||||
buffer.WriteInt(message.ddd.Length);
|
||||
int length9 = message.ddd.Length;
|
||||
for (int i10 = 0; i10 < length9; i10++)
|
||||
{
|
||||
long element11 = message.ddd[i10];
|
||||
buffer.WriteLong(element11);
|
||||
}
|
||||
}
|
||||
buffer.WriteFloat(message.e);
|
||||
if ((message.eee == null) || (message.eee.Length == 0))
|
||||
{
|
||||
buffer.WriteInt(0);
|
||||
}
|
||||
else
|
||||
{
|
||||
buffer.WriteInt(message.eee.Length);
|
||||
int length12 = message.eee.Length;
|
||||
for (int i13 = 0; i13 < length12; i13++)
|
||||
{
|
||||
float element14 = message.eee[i13];
|
||||
buffer.WriteFloat(element14);
|
||||
}
|
||||
}
|
||||
buffer.WriteDouble(message.f);
|
||||
if ((message.fff == null) || (message.fff.Length == 0))
|
||||
{
|
||||
buffer.WriteInt(0);
|
||||
}
|
||||
else
|
||||
{
|
||||
buffer.WriteInt(message.fff.Length);
|
||||
int length15 = message.fff.Length;
|
||||
for (int i16 = 0; i16 < length15; i16++)
|
||||
{
|
||||
double element17 = message.fff[i16];
|
||||
buffer.WriteDouble(element17);
|
||||
}
|
||||
}
|
||||
buffer.WriteBool(message.g);
|
||||
if ((message.ggg == null) || (message.ggg.Length == 0))
|
||||
{
|
||||
buffer.WriteInt(0);
|
||||
}
|
||||
else
|
||||
{
|
||||
buffer.WriteInt(message.ggg.Length);
|
||||
int length18 = message.ggg.Length;
|
||||
for (int i19 = 0; i19 < length18; i19++)
|
||||
{
|
||||
bool element20 = message.ggg[i19];
|
||||
buffer.WriteBool(element20);
|
||||
}
|
||||
}
|
||||
buffer.WriteChar(message.h);
|
||||
if ((message.hhh == null) || (message.hhh.Length == 0))
|
||||
{
|
||||
buffer.WriteInt(0);
|
||||
}
|
||||
else
|
||||
{
|
||||
buffer.WriteInt(message.hhh.Length);
|
||||
int length21 = message.hhh.Length;
|
||||
for (int i22 = 0; i22 < length21; i22++)
|
||||
{
|
||||
char element23 = message.hhh[i22];
|
||||
buffer.WriteChar(element23);
|
||||
}
|
||||
}
|
||||
buffer.WriteString(message.jj);
|
||||
if ((message.jjj == null) || (message.jjj.Length == 0))
|
||||
{
|
||||
buffer.WriteInt(0);
|
||||
}
|
||||
else
|
||||
{
|
||||
buffer.WriteInt(message.jjj.Length);
|
||||
int length24 = message.jjj.Length;
|
||||
for (int i25 = 0; i25 < length24; i25++)
|
||||
{
|
||||
string element26 = message.jjj[i25];
|
||||
buffer.WriteString(element26);
|
||||
}
|
||||
}
|
||||
ProtocolManager.GetProtocol(1116).Write(buffer, message.kk);
|
||||
if ((message.kkk == null) || (message.kkk.Length == 0))
|
||||
{
|
||||
buffer.WriteInt(0);
|
||||
}
|
||||
else
|
||||
{
|
||||
buffer.WriteInt(message.kkk.Length);
|
||||
int length27 = message.kkk.Length;
|
||||
for (int i28 = 0; i28 < length27; i28++)
|
||||
{
|
||||
ObjectA element29 = message.kkk[i28];
|
||||
ProtocolManager.GetProtocol(1116).Write(buffer, element29);
|
||||
}
|
||||
}
|
||||
if (message.l == null)
|
||||
{
|
||||
buffer.WriteInt(0);
|
||||
}
|
||||
else
|
||||
{
|
||||
buffer.WriteInt(message.l.Count);
|
||||
int length30 = message.l.Count;
|
||||
for (int i31 = 0; i31 < length30; i31++)
|
||||
{
|
||||
var element32 = message.l[i31];
|
||||
buffer.WriteInt(element32);
|
||||
}
|
||||
}
|
||||
if (message.llll == null)
|
||||
{
|
||||
buffer.WriteInt(0);
|
||||
}
|
||||
else
|
||||
{
|
||||
buffer.WriteInt(message.llll.Count);
|
||||
int length33 = message.llll.Count;
|
||||
for (int i34 = 0; i34 < length33; i34++)
|
||||
{
|
||||
var element35 = message.llll[i34];
|
||||
buffer.WriteString(element35);
|
||||
}
|
||||
}
|
||||
if ((message.m == null) || (message.m.Count == 0))
|
||||
{
|
||||
buffer.WriteInt(0);
|
||||
}
|
||||
else
|
||||
{
|
||||
buffer.WriteInt(message.m.Count);
|
||||
foreach (var i36 in message.m)
|
||||
{
|
||||
var keyElement37 = i36.Key;
|
||||
var valueElement38 = i36.Value;
|
||||
buffer.WriteInt(keyElement37);
|
||||
buffer.WriteString(valueElement38);
|
||||
}
|
||||
}
|
||||
if ((message.mm == null) || (message.mm.Count == 0))
|
||||
{
|
||||
buffer.WriteInt(0);
|
||||
}
|
||||
else
|
||||
{
|
||||
buffer.WriteInt(message.mm.Count);
|
||||
foreach (var i39 in message.mm)
|
||||
{
|
||||
var keyElement40 = i39.Key;
|
||||
var valueElement41 = i39.Value;
|
||||
buffer.WriteInt(keyElement40);
|
||||
ProtocolManager.GetProtocol(1116).Write(buffer, valueElement41);
|
||||
}
|
||||
}
|
||||
if (message.s == null)
|
||||
{
|
||||
buffer.WriteInt(0);
|
||||
}
|
||||
else
|
||||
{
|
||||
buffer.WriteInt(message.s.Count);
|
||||
foreach (var i42 in message.s)
|
||||
{
|
||||
buffer.WriteInt(i42);
|
||||
}
|
||||
}
|
||||
if (message.ssss == null)
|
||||
{
|
||||
buffer.WriteInt(0);
|
||||
}
|
||||
else
|
||||
{
|
||||
buffer.WriteInt(message.ssss.Count);
|
||||
foreach (var i43 in message.ssss)
|
||||
{
|
||||
buffer.WriteString(i43);
|
||||
}
|
||||
}
|
||||
ProtocolManager.GetProtocol(102).Write(buffer, message.kk);
|
||||
buffer.WriteIntList(message.l);
|
||||
buffer.WriteLongList(message.ll);
|
||||
buffer.WritePacketList(message.lll, 102);
|
||||
buffer.WriteStringList(message.llll);
|
||||
buffer.WriteIntStringMap(message.m);
|
||||
buffer.WriteIntPacketMap(message.mm, 102);
|
||||
buffer.WriteIntSet(message.s);
|
||||
buffer.WriteStringSet(message.ssss);
|
||||
}
|
||||
|
||||
public IPacket Read(ByteBuffer buffer)
|
||||
@@ -333,204 +100,42 @@ namespace CsProtocol
|
||||
return null;
|
||||
}
|
||||
NormalObject packet = new NormalObject();
|
||||
byte result44 = buffer.ReadByte();
|
||||
packet.a = result44;
|
||||
int size47 = buffer.ReadInt();
|
||||
byte[] result45 = new byte[size47];
|
||||
if (size47 > 0)
|
||||
{
|
||||
for (int index46 = 0; index46 < size47; index46++)
|
||||
{
|
||||
byte result48 = buffer.ReadByte();
|
||||
result45[index46] = result48;
|
||||
}
|
||||
}
|
||||
packet.aaa = result45;
|
||||
short result49 = buffer.ReadShort();
|
||||
packet.b = result49;
|
||||
int size52 = buffer.ReadInt();
|
||||
short[] result50 = new short[size52];
|
||||
if (size52 > 0)
|
||||
{
|
||||
for (int index51 = 0; index51 < size52; index51++)
|
||||
{
|
||||
short result53 = buffer.ReadShort();
|
||||
result50[index51] = result53;
|
||||
}
|
||||
}
|
||||
packet.bbb = result50;
|
||||
int result54 = buffer.ReadInt();
|
||||
packet.c = result54;
|
||||
int size57 = buffer.ReadInt();
|
||||
int[] result55 = new int[size57];
|
||||
if (size57 > 0)
|
||||
{
|
||||
for (int index56 = 0; index56 < size57; index56++)
|
||||
{
|
||||
int result58 = buffer.ReadInt();
|
||||
result55[index56] = result58;
|
||||
}
|
||||
}
|
||||
packet.ccc = result55;
|
||||
long result59 = buffer.ReadLong();
|
||||
packet.d = result59;
|
||||
int size62 = buffer.ReadInt();
|
||||
long[] result60 = new long[size62];
|
||||
if (size62 > 0)
|
||||
{
|
||||
for (int index61 = 0; index61 < size62; index61++)
|
||||
{
|
||||
long result63 = buffer.ReadLong();
|
||||
result60[index61] = result63;
|
||||
}
|
||||
}
|
||||
packet.ddd = result60;
|
||||
float result64 = buffer.ReadFloat();
|
||||
packet.e = result64;
|
||||
int size67 = buffer.ReadInt();
|
||||
float[] result65 = new float[size67];
|
||||
if (size67 > 0)
|
||||
{
|
||||
for (int index66 = 0; index66 < size67; index66++)
|
||||
{
|
||||
float result68 = buffer.ReadFloat();
|
||||
result65[index66] = result68;
|
||||
}
|
||||
}
|
||||
packet.eee = result65;
|
||||
double result69 = buffer.ReadDouble();
|
||||
packet.f = result69;
|
||||
int size72 = buffer.ReadInt();
|
||||
double[] result70 = new double[size72];
|
||||
if (size72 > 0)
|
||||
{
|
||||
for (int index71 = 0; index71 < size72; index71++)
|
||||
{
|
||||
double result73 = buffer.ReadDouble();
|
||||
result70[index71] = result73;
|
||||
}
|
||||
}
|
||||
packet.fff = result70;
|
||||
bool result74 = buffer.ReadBool();
|
||||
packet.g = result74;
|
||||
int size77 = buffer.ReadInt();
|
||||
bool[] result75 = new bool[size77];
|
||||
if (size77 > 0)
|
||||
{
|
||||
for (int index76 = 0; index76 < size77; index76++)
|
||||
{
|
||||
bool result78 = buffer.ReadBool();
|
||||
result75[index76] = result78;
|
||||
}
|
||||
}
|
||||
packet.ggg = result75;
|
||||
char result79 = buffer.ReadChar();
|
||||
packet.h = result79;
|
||||
int size82 = buffer.ReadInt();
|
||||
char[] result80 = new char[size82];
|
||||
if (size82 > 0)
|
||||
{
|
||||
for (int index81 = 0; index81 < size82; index81++)
|
||||
{
|
||||
char result83 = buffer.ReadChar();
|
||||
result80[index81] = result83;
|
||||
}
|
||||
}
|
||||
packet.hhh = result80;
|
||||
string result84 = buffer.ReadString();
|
||||
packet.jj = result84;
|
||||
int size87 = buffer.ReadInt();
|
||||
string[] result85 = new string[size87];
|
||||
if (size87 > 0)
|
||||
{
|
||||
for (int index86 = 0; index86 < size87; index86++)
|
||||
{
|
||||
string result88 = buffer.ReadString();
|
||||
result85[index86] = result88;
|
||||
}
|
||||
}
|
||||
packet.jjj = result85;
|
||||
ObjectA result89 = (ObjectA) ProtocolManager.GetProtocol(1116).Read(buffer);
|
||||
packet.kk = result89;
|
||||
int size92 = buffer.ReadInt();
|
||||
ObjectA[] result90 = new ObjectA[size92];
|
||||
if (size92 > 0)
|
||||
{
|
||||
for (int index91 = 0; index91 < size92; index91++)
|
||||
{
|
||||
ObjectA result93 = (ObjectA) ProtocolManager.GetProtocol(1116).Read(buffer);
|
||||
result90[index91] = result93;
|
||||
}
|
||||
}
|
||||
packet.kkk = result90;
|
||||
int size96 = buffer.ReadInt();
|
||||
var result94 = new List<int>(size96);
|
||||
if (size96 > 0)
|
||||
{
|
||||
for (int index95 = 0; index95 < size96; index95++)
|
||||
{
|
||||
int result97 = buffer.ReadInt();
|
||||
result94.Add(result97);
|
||||
}
|
||||
}
|
||||
packet.l = result94;
|
||||
int size100 = buffer.ReadInt();
|
||||
var result98 = new List<string>(size100);
|
||||
if (size100 > 0)
|
||||
{
|
||||
for (int index99 = 0; index99 < size100; index99++)
|
||||
{
|
||||
string result101 = buffer.ReadString();
|
||||
result98.Add(result101);
|
||||
}
|
||||
}
|
||||
packet.llll = result98;
|
||||
int size103 = buffer.ReadInt();
|
||||
var result102 = new Dictionary<int, string>(size103);
|
||||
if (size103 > 0)
|
||||
{
|
||||
for (var index104 = 0; index104 < size103; index104++)
|
||||
{
|
||||
int result105 = buffer.ReadInt();
|
||||
string result106 = buffer.ReadString();
|
||||
result102[result105] = result106;
|
||||
}
|
||||
}
|
||||
packet.m = result102;
|
||||
int size108 = buffer.ReadInt();
|
||||
var result107 = new Dictionary<int, ObjectA>(size108);
|
||||
if (size108 > 0)
|
||||
{
|
||||
for (var index109 = 0; index109 < size108; index109++)
|
||||
{
|
||||
int result110 = buffer.ReadInt();
|
||||
ObjectA result111 = (ObjectA) ProtocolManager.GetProtocol(1116).Read(buffer);
|
||||
result107[result110] = result111;
|
||||
}
|
||||
}
|
||||
packet.mm = result107;
|
||||
int size114 = buffer.ReadInt();
|
||||
var result112 = new HashSet<int>();
|
||||
if (size114 > 0)
|
||||
{
|
||||
for (int index113 = 0; index113 < size114; index113++)
|
||||
{
|
||||
int result115 = buffer.ReadInt();
|
||||
result112.Add(result115);
|
||||
}
|
||||
}
|
||||
packet.s = result112;
|
||||
int size118 = buffer.ReadInt();
|
||||
var result116 = new HashSet<string>();
|
||||
if (size118 > 0)
|
||||
{
|
||||
for (int index117 = 0; index117 < size118; index117++)
|
||||
{
|
||||
string result119 = buffer.ReadString();
|
||||
result116.Add(result119);
|
||||
}
|
||||
}
|
||||
packet.ssss = result116;
|
||||
byte result0 = buffer.ReadByte();
|
||||
packet.a = result0;
|
||||
var array1 = buffer.ReadByteArray();
|
||||
packet.aaa = array1;
|
||||
short result2 = buffer.ReadShort();
|
||||
packet.b = result2;
|
||||
int result3 = buffer.ReadInt();
|
||||
packet.c = result3;
|
||||
long result4 = buffer.ReadLong();
|
||||
packet.d = result4;
|
||||
float result5 = buffer.ReadFloat();
|
||||
packet.e = result5;
|
||||
double result6 = buffer.ReadDouble();
|
||||
packet.f = result6;
|
||||
bool result7 = buffer.ReadBool();
|
||||
packet.g = result7;
|
||||
string result8 = buffer.ReadString();
|
||||
packet.jj = result8;
|
||||
ObjectA result9 = (ObjectA) ProtocolManager.GetProtocol(102).Read(buffer);
|
||||
packet.kk = result9;
|
||||
var list10 = buffer.ReadIntList();
|
||||
packet.l = list10;
|
||||
var list11 = buffer.ReadLongList();
|
||||
packet.ll = list11;
|
||||
var list12 = buffer.ReadPacketList<ObjectA>(102);
|
||||
packet.lll = list12;
|
||||
var list13 = buffer.ReadStringList();
|
||||
packet.llll = list13;
|
||||
var map14 = buffer.ReadIntStringMap();
|
||||
packet.m = map14;
|
||||
var map15 = buffer.ReadIntPacketMap<ObjectA>(102);
|
||||
packet.mm = map15;
|
||||
var set16 = buffer.ReadIntSet();
|
||||
packet.s = set16;
|
||||
var set17 = buffer.ReadStringSet();
|
||||
packet.ssss = set17;
|
||||
return packet;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,8 +5,7 @@ using CsProtocol.Buffer;
|
||||
namespace CsProtocol
|
||||
{
|
||||
// @author jaysunxiao
|
||||
// @version 1.0
|
||||
// @since 2017 10.12 15:39
|
||||
// @version 3.0
|
||||
public class ObjectA : IPacket
|
||||
{
|
||||
public int a;
|
||||
@@ -25,7 +24,7 @@ namespace CsProtocol
|
||||
|
||||
public short ProtocolId()
|
||||
{
|
||||
return 1116;
|
||||
return 102;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,35 +33,19 @@ namespace CsProtocol
|
||||
{
|
||||
public short ProtocolId()
|
||||
{
|
||||
return 1116;
|
||||
return 102;
|
||||
}
|
||||
|
||||
public void Write(ByteBuffer buffer, IPacket packet)
|
||||
{
|
||||
if (packet == null)
|
||||
if (buffer.WritePacketFlag(packet))
|
||||
{
|
||||
buffer.WriteBool(false);
|
||||
return;
|
||||
}
|
||||
buffer.WriteBool(true);
|
||||
ObjectA message = (ObjectA) packet;
|
||||
buffer.WriteInt(message.a);
|
||||
if ((message.m == null) || (message.m.Count == 0))
|
||||
{
|
||||
buffer.WriteInt(0);
|
||||
}
|
||||
else
|
||||
{
|
||||
buffer.WriteInt(message.m.Count);
|
||||
foreach (var i0 in message.m)
|
||||
{
|
||||
var keyElement1 = i0.Key;
|
||||
var valueElement2 = i0.Value;
|
||||
buffer.WriteInt(keyElement1);
|
||||
buffer.WriteString(valueElement2);
|
||||
}
|
||||
}
|
||||
ProtocolManager.GetProtocol(1117).Write(buffer, message.objectB);
|
||||
buffer.WriteIntStringMap(message.m);
|
||||
ProtocolManager.GetProtocol(103).Write(buffer, message.objectB);
|
||||
}
|
||||
|
||||
public IPacket Read(ByteBuffer buffer)
|
||||
@@ -72,22 +55,12 @@ namespace CsProtocol
|
||||
return null;
|
||||
}
|
||||
ObjectA packet = new ObjectA();
|
||||
int result3 = buffer.ReadInt();
|
||||
packet.a = result3;
|
||||
int size5 = buffer.ReadInt();
|
||||
var result4 = new Dictionary<int, string>(size5);
|
||||
if (size5 > 0)
|
||||
{
|
||||
for (var index6 = 0; index6 < size5; index6++)
|
||||
{
|
||||
int result7 = buffer.ReadInt();
|
||||
string result8 = buffer.ReadString();
|
||||
result4[result7] = result8;
|
||||
}
|
||||
}
|
||||
packet.m = result4;
|
||||
ObjectB result9 = (ObjectB) ProtocolManager.GetProtocol(1117).Read(buffer);
|
||||
packet.objectB = result9;
|
||||
int result0 = buffer.ReadInt();
|
||||
packet.a = result0;
|
||||
var map1 = buffer.ReadIntStringMap();
|
||||
packet.m = map1;
|
||||
ObjectB result2 = (ObjectB) ProtocolManager.GetProtocol(103).Read(buffer);
|
||||
packet.objectB = result2;
|
||||
return packet;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,8 +5,7 @@ using CsProtocol.Buffer;
|
||||
namespace CsProtocol
|
||||
{
|
||||
// @author jaysunxiao
|
||||
// @version 1.0
|
||||
// @since 2017 10.12 15:39
|
||||
// @version 3.0
|
||||
public class ObjectB : IPacket
|
||||
{
|
||||
public bool flag;
|
||||
@@ -21,7 +20,7 @@ namespace CsProtocol
|
||||
|
||||
public short ProtocolId()
|
||||
{
|
||||
return 1117;
|
||||
return 103;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,17 +29,15 @@ namespace CsProtocol
|
||||
{
|
||||
public short ProtocolId()
|
||||
{
|
||||
return 1117;
|
||||
return 103;
|
||||
}
|
||||
|
||||
public void Write(ByteBuffer buffer, IPacket packet)
|
||||
{
|
||||
if (packet == null)
|
||||
if (buffer.WritePacketFlag(packet))
|
||||
{
|
||||
buffer.WriteBool(false);
|
||||
return;
|
||||
}
|
||||
buffer.WriteBool(true);
|
||||
ObjectB message = (ObjectB) packet;
|
||||
buffer.WriteBool(message.flag);
|
||||
}
|
||||
|
||||
@@ -5,8 +5,7 @@ using CsProtocol.Buffer;
|
||||
namespace CsProtocol
|
||||
{
|
||||
// @author jaysunxiao
|
||||
// @version 1.0
|
||||
// @since 2021-03-27 15:18
|
||||
// @version 3.0
|
||||
public class SimpleObject : IPacket
|
||||
{
|
||||
public int c;
|
||||
@@ -23,7 +22,7 @@ namespace CsProtocol
|
||||
|
||||
public short ProtocolId()
|
||||
{
|
||||
return 1163;
|
||||
return 104;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,17 +31,15 @@ namespace CsProtocol
|
||||
{
|
||||
public short ProtocolId()
|
||||
{
|
||||
return 1163;
|
||||
return 104;
|
||||
}
|
||||
|
||||
public void Write(ByteBuffer buffer, IPacket packet)
|
||||
{
|
||||
if (packet == null)
|
||||
if (buffer.WritePacketFlag(packet))
|
||||
{
|
||||
buffer.WriteBool(false);
|
||||
return;
|
||||
}
|
||||
buffer.WriteBool(true);
|
||||
SimpleObject message = (SimpleObject) packet;
|
||||
buffer.WriteInt(message.c);
|
||||
buffer.WriteBool(message.g);
|
||||
|
||||
@@ -50,20 +50,20 @@ namespace CsProtocol
|
||||
return protocol;
|
||||
}
|
||||
|
||||
public static void Write(ByteBuffer byteBuffer, IPacket packet)
|
||||
public static void Write(ByteBuffer buffer, IPacket packet)
|
||||
{
|
||||
var protocolId = packet.ProtocolId();
|
||||
// 写入协议号
|
||||
byteBuffer.WriteShort(protocolId);
|
||||
buffer.WriteShort(protocolId);
|
||||
|
||||
// 写入包体
|
||||
GetProtocol(protocolId).Write(byteBuffer, packet);
|
||||
GetProtocol(protocolId).Write(buffer, packet);
|
||||
}
|
||||
|
||||
public static IPacket Read(ByteBuffer byteBuffer)
|
||||
public static IPacket Read(ByteBuffer buffer)
|
||||
{
|
||||
var protocolId = byteBuffer.ReadShort();
|
||||
return GetProtocol(protocolId).Read(byteBuffer);
|
||||
var protocolId = buffer.ReadShort();
|
||||
return GetProtocol(protocolId).Read(buffer);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user