mirror of
https://github.com/tiennm99/zfoo.git
synced 2026-10-19 20:15:46 +00:00
ref[protocol]: 重构protocol的CSharp的解析
This commit is contained in:
1 parent
a30397f3a3
commit
7fc244fe92
14 files changed
+1896
-1709
No files matched your search
@@ -204,7 +204,7 @@ public class CutDownListSerializer implements ICutDownSerializer {
|
|||||||
builder.append(StringUtils.format("buffer.writePacketArray({}, {})", objectStr, objectProtocolField.getProtocolId())).append(LS);
|
builder.append(StringUtils.format("buffer.writePacketArray({}, {})", objectStr, objectProtocolField.getProtocolId())).append(LS);
|
||||||
break;
|
break;
|
||||||
case CSharp:
|
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;
|
break;
|
||||||
default:
|
default:
|
||||||
flag = false;
|
flag = false;
|
||||||
|
|||||||
@@ -109,7 +109,7 @@ public class CutDownMapSerializer implements ICutDownSerializer {
|
|||||||
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;
|
return true;
|
||||||
case CSharp:
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -171,7 +171,7 @@ public class CutDownMapSerializer implements ICutDownSerializer {
|
|||||||
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;
|
return true;
|
||||||
case CSharp:
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -233,7 +233,7 @@ public class CutDownMapSerializer implements ICutDownSerializer {
|
|||||||
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;
|
return true;
|
||||||
case CSharp:
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -312,7 +312,7 @@ public class CutDownMapSerializer implements ICutDownSerializer {
|
|||||||
builder.append(StringUtils.format("var {} = buffer.readIntPacketMap({})", map, ((ObjectProtocolField) valueRegistration).getProtocolId())).append(LS);
|
builder.append(StringUtils.format("var {} = buffer.readIntPacketMap({})", map, ((ObjectProtocolField) valueRegistration).getProtocolId())).append(LS);
|
||||||
return map;
|
return map;
|
||||||
case CSharp:
|
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;
|
return map;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -202,7 +202,7 @@ public class CutDownSetSerializer implements ICutDownSerializer {
|
|||||||
builder.append(StringUtils.format("buffer.writePacketArray({}, {})", objectStr, objectProtocolField.getProtocolId())).append(LS);
|
builder.append(StringUtils.format("buffer.writePacketArray({}, {})", objectStr, objectProtocolField.getProtocolId())).append(LS);
|
||||||
break;
|
break;
|
||||||
case CSharp:
|
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;
|
break;
|
||||||
default:
|
default:
|
||||||
flag = false;
|
flag = false;
|
||||||
|
|||||||
@@ -60,7 +60,8 @@ namespace CsProtocol.Buffer
|
|||||||
{
|
{
|
||||||
if (writeIndex > buffer.Length)
|
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 +
|
", writerIndex: " + writeOffset +
|
||||||
"(expected: 0 <= readerIndex <= writerIndex <= capacity:" + buffer.Length);
|
"(expected: 0 <= readerIndex <= writerIndex <= capacity:" + buffer.Length);
|
||||||
}
|
}
|
||||||
@@ -593,6 +594,7 @@ namespace CsProtocol.Buffer
|
|||||||
array[index] = ReadBool();
|
array[index] = ReadBool();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return array;
|
return array;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -624,6 +626,7 @@ namespace CsProtocol.Buffer
|
|||||||
array[index] = ReadByte();
|
array[index] = ReadByte();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return array;
|
return array;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -655,6 +658,7 @@ namespace CsProtocol.Buffer
|
|||||||
array[index] = ReadShort();
|
array[index] = ReadShort();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return array;
|
return array;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -686,6 +690,7 @@ namespace CsProtocol.Buffer
|
|||||||
array[index] = ReadInt();
|
array[index] = ReadInt();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return array;
|
return array;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -717,6 +722,7 @@ namespace CsProtocol.Buffer
|
|||||||
array[index] = ReadLong();
|
array[index] = ReadLong();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return array;
|
return array;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -748,6 +754,7 @@ namespace CsProtocol.Buffer
|
|||||||
array[index] = ReadLong();
|
array[index] = ReadLong();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return array;
|
return array;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -779,6 +786,7 @@ namespace CsProtocol.Buffer
|
|||||||
array[index] = ReadLong();
|
array[index] = ReadLong();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return array;
|
return array;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -810,6 +818,7 @@ namespace CsProtocol.Buffer
|
|||||||
array[index] = ReadChar();
|
array[index] = ReadChar();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return array;
|
return array;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -841,6 +850,7 @@ namespace CsProtocol.Buffer
|
|||||||
array[index] = ReadString();
|
array[index] = ReadString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return array;
|
return array;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -874,6 +884,7 @@ namespace CsProtocol.Buffer
|
|||||||
array[index] = (T) protocolRegistration.Read(this);
|
array[index] = (T) protocolRegistration.Read(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return array;
|
return array;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -905,6 +916,7 @@ namespace CsProtocol.Buffer
|
|||||||
list.Add(ReadBool());
|
list.Add(ReadBool());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -936,6 +948,7 @@ namespace CsProtocol.Buffer
|
|||||||
list.Add(ReadByte());
|
list.Add(ReadByte());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -967,6 +980,7 @@ namespace CsProtocol.Buffer
|
|||||||
list.Add(ReadShort());
|
list.Add(ReadShort());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -998,6 +1012,7 @@ namespace CsProtocol.Buffer
|
|||||||
list.Add(ReadInt());
|
list.Add(ReadInt());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1029,6 +1044,7 @@ namespace CsProtocol.Buffer
|
|||||||
list.Add(ReadLong());
|
list.Add(ReadLong());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1060,6 +1076,7 @@ namespace CsProtocol.Buffer
|
|||||||
list.Add(ReadFloat());
|
list.Add(ReadFloat());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1091,6 +1108,7 @@ namespace CsProtocol.Buffer
|
|||||||
list.Add(ReadDouble());
|
list.Add(ReadDouble());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1122,6 +1140,7 @@ namespace CsProtocol.Buffer
|
|||||||
list.Add(ReadChar());
|
list.Add(ReadChar());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1153,6 +1172,7 @@ namespace CsProtocol.Buffer
|
|||||||
list.Add(ReadString());
|
list.Add(ReadString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1186,6 +1206,7 @@ namespace CsProtocol.Buffer
|
|||||||
list.Add((T) protocolRegistration.Read(this));
|
list.Add((T) protocolRegistration.Read(this));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1208,7 +1229,7 @@ namespace CsProtocol.Buffer
|
|||||||
public HashSet<bool> ReadBooleanSet()
|
public HashSet<bool> ReadBooleanSet()
|
||||||
{
|
{
|
||||||
int size = ReadInt();
|
int size = ReadInt();
|
||||||
HashSet<bool> set = new HashSet<bool>(size);
|
HashSet<bool> set = new HashSet<bool>();
|
||||||
if (size > 0)
|
if (size > 0)
|
||||||
{
|
{
|
||||||
for (int index = 0; index < size; index++)
|
for (int index = 0; index < size; index++)
|
||||||
@@ -1216,6 +1237,7 @@ namespace CsProtocol.Buffer
|
|||||||
set.Add(ReadBool());
|
set.Add(ReadBool());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return set;
|
return set;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1238,7 +1260,7 @@ namespace CsProtocol.Buffer
|
|||||||
public HashSet<short> ReadShortSet()
|
public HashSet<short> ReadShortSet()
|
||||||
{
|
{
|
||||||
int size = ReadInt();
|
int size = ReadInt();
|
||||||
HashSet<short> set = new HashSet<short>(size);
|
HashSet<short> set = new HashSet<short>();
|
||||||
if (size > 0)
|
if (size > 0)
|
||||||
{
|
{
|
||||||
for (int index = 0; index < size; index++)
|
for (int index = 0; index < size; index++)
|
||||||
@@ -1246,6 +1268,7 @@ namespace CsProtocol.Buffer
|
|||||||
set.Add(ReadShort());
|
set.Add(ReadShort());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return set;
|
return set;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1268,7 +1291,7 @@ namespace CsProtocol.Buffer
|
|||||||
public HashSet<int> ReadIntSet()
|
public HashSet<int> ReadIntSet()
|
||||||
{
|
{
|
||||||
int size = ReadInt();
|
int size = ReadInt();
|
||||||
HashSet<int> set = new HashSet<int>(size);
|
HashSet<int> set = new HashSet<int>();
|
||||||
if (size > 0)
|
if (size > 0)
|
||||||
{
|
{
|
||||||
for (int index = 0; index < size; index++)
|
for (int index = 0; index < size; index++)
|
||||||
@@ -1276,6 +1299,7 @@ namespace CsProtocol.Buffer
|
|||||||
set.Add(ReadInt());
|
set.Add(ReadInt());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return set;
|
return set;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1298,7 +1322,7 @@ namespace CsProtocol.Buffer
|
|||||||
public HashSet<long> ReadLongSet()
|
public HashSet<long> ReadLongSet()
|
||||||
{
|
{
|
||||||
int size = ReadInt();
|
int size = ReadInt();
|
||||||
HashSet<long> set = new HashSet<long>(size);
|
HashSet<long> set = new HashSet<long>();
|
||||||
if (size > 0)
|
if (size > 0)
|
||||||
{
|
{
|
||||||
for (int index = 0; index < size; index++)
|
for (int index = 0; index < size; index++)
|
||||||
@@ -1306,6 +1330,7 @@ namespace CsProtocol.Buffer
|
|||||||
set.Add(ReadLong());
|
set.Add(ReadLong());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return set;
|
return set;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1328,7 +1353,7 @@ namespace CsProtocol.Buffer
|
|||||||
public HashSet<float> ReadFloatSet()
|
public HashSet<float> ReadFloatSet()
|
||||||
{
|
{
|
||||||
int size = ReadInt();
|
int size = ReadInt();
|
||||||
HashSet<float> set = new HashSet<float>(size);
|
HashSet<float> set = new HashSet<float>();
|
||||||
if (size > 0)
|
if (size > 0)
|
||||||
{
|
{
|
||||||
for (int index = 0; index < size; index++)
|
for (int index = 0; index < size; index++)
|
||||||
@@ -1336,6 +1361,7 @@ namespace CsProtocol.Buffer
|
|||||||
set.Add(ReadFloat());
|
set.Add(ReadFloat());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return set;
|
return set;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1358,7 +1384,7 @@ namespace CsProtocol.Buffer
|
|||||||
public HashSet<double> ReadDoubleSet()
|
public HashSet<double> ReadDoubleSet()
|
||||||
{
|
{
|
||||||
int size = ReadInt();
|
int size = ReadInt();
|
||||||
HashSet<double> set = new HashSet<double>(size);
|
HashSet<double> set = new HashSet<double>();
|
||||||
if (size > 0)
|
if (size > 0)
|
||||||
{
|
{
|
||||||
for (int index = 0; index < size; index++)
|
for (int index = 0; index < size; index++)
|
||||||
@@ -1366,6 +1392,7 @@ namespace CsProtocol.Buffer
|
|||||||
set.Add(ReadDouble());
|
set.Add(ReadDouble());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return set;
|
return set;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1388,7 +1415,7 @@ namespace CsProtocol.Buffer
|
|||||||
public HashSet<char> ReadCharSet()
|
public HashSet<char> ReadCharSet()
|
||||||
{
|
{
|
||||||
int size = ReadInt();
|
int size = ReadInt();
|
||||||
HashSet<char> set = new HashSet<char>(size);
|
HashSet<char> set = new HashSet<char>();
|
||||||
if (size > 0)
|
if (size > 0)
|
||||||
{
|
{
|
||||||
for (int index = 0; index < size; index++)
|
for (int index = 0; index < size; index++)
|
||||||
@@ -1396,6 +1423,7 @@ namespace CsProtocol.Buffer
|
|||||||
set.Add(ReadChar());
|
set.Add(ReadChar());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return set;
|
return set;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1418,7 +1446,7 @@ namespace CsProtocol.Buffer
|
|||||||
public HashSet<string> ReadStringSet()
|
public HashSet<string> ReadStringSet()
|
||||||
{
|
{
|
||||||
int size = ReadInt();
|
int size = ReadInt();
|
||||||
HashSet<string> set = new HashSet<string>(size);
|
HashSet<string> set = new HashSet<string>();
|
||||||
if (size > 0)
|
if (size > 0)
|
||||||
{
|
{
|
||||||
for (int index = 0; index < size; index++)
|
for (int index = 0; index < size; index++)
|
||||||
@@ -1426,6 +1454,7 @@ namespace CsProtocol.Buffer
|
|||||||
set.Add(ReadString());
|
set.Add(ReadString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return set;
|
return set;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1449,7 +1478,7 @@ namespace CsProtocol.Buffer
|
|||||||
public HashSet<T> ReadPacketSet<T>(short protocolId)
|
public HashSet<T> ReadPacketSet<T>(short protocolId)
|
||||||
{
|
{
|
||||||
int size = ReadInt();
|
int size = ReadInt();
|
||||||
HashSet<T> set = new HashSet<T>(size);
|
HashSet<T> set = new HashSet<T>();
|
||||||
if (size > 0)
|
if (size > 0)
|
||||||
{
|
{
|
||||||
IProtocolRegistration protocolRegistration = ProtocolManager.GetProtocol(protocolId);
|
IProtocolRegistration protocolRegistration = ProtocolManager.GetProtocol(protocolId);
|
||||||
@@ -1458,6 +1487,7 @@ namespace CsProtocol.Buffer
|
|||||||
set.Add((T) protocolRegistration.Read(this));
|
set.Add((T) protocolRegistration.Read(this));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return set;
|
return set;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1491,6 +1521,7 @@ namespace CsProtocol.Buffer
|
|||||||
map[key] = value;
|
map[key] = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1524,6 +1555,7 @@ namespace CsProtocol.Buffer
|
|||||||
map[key] = value;
|
map[key] = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1557,44 +1589,46 @@ namespace CsProtocol.Buffer
|
|||||||
map[key] = value;
|
map[key] = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void WriteIntPacketMap<T>(Dictionary<int, T> map, short protocolId)
|
public void WriteIntPacketMap<T>(Dictionary<int, T> map, short protocolId)
|
||||||
{
|
{
|
||||||
if ((map == null) || (map.Count == 0))
|
if ((map == null) || (map.Count == 0))
|
||||||
{
|
{
|
||||||
WriteInt(0);
|
WriteInt(0);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
IProtocolRegistration protocolRegistration = ProtocolManager.GetProtocol(protocolId);
|
IProtocolRegistration protocolRegistration = ProtocolManager.GetProtocol(protocolId);
|
||||||
WriteInt(map.Count);
|
WriteInt(map.Count);
|
||||||
foreach (var element in map)
|
foreach (var element in map)
|
||||||
{
|
{
|
||||||
WriteInt(element.Key);
|
WriteInt(element.Key);
|
||||||
protocolRegistration.Write(this, (IPacket) element.Value);
|
protocolRegistration.Write(this, (IPacket) element.Value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Dictionary<int, T> ReadIntPacketMap<T>(short protocolId)
|
public Dictionary<int, T> ReadIntPacketMap<T>(short protocolId)
|
||||||
{
|
{
|
||||||
int size = ReadInt();
|
int size = ReadInt();
|
||||||
Dictionary<int, T> map = new Dictionary<int, T>(size);
|
Dictionary<int, T> map = new Dictionary<int, T>(size);
|
||||||
if (size > 0)
|
if (size > 0)
|
||||||
{
|
{
|
||||||
IProtocolRegistration protocolRegistration = ProtocolManager.GetProtocol(protocolId);
|
IProtocolRegistration protocolRegistration = ProtocolManager.GetProtocol(protocolId);
|
||||||
for (int index = 0; index < size; index++)
|
for (int index = 0; index < size; index++)
|
||||||
{
|
{
|
||||||
var key = ReadInt();
|
var key = ReadInt();
|
||||||
var value = (T) protocolRegistration.Read(this);
|
var value = (T) protocolRegistration.Read(this);
|
||||||
map[key] = value;
|
map[key] = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return map;
|
|
||||||
}
|
return map;
|
||||||
|
}
|
||||||
|
|
||||||
public void WriteLongIntMap(Dictionary<long, int> map)
|
public void WriteLongIntMap(Dictionary<long, int> map)
|
||||||
{
|
{
|
||||||
@@ -1626,6 +1660,7 @@ namespace CsProtocol.Buffer
|
|||||||
map[key] = value;
|
map[key] = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1659,6 +1694,7 @@ namespace CsProtocol.Buffer
|
|||||||
map[key] = value;
|
map[key] = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1692,44 +1728,46 @@ namespace CsProtocol.Buffer
|
|||||||
map[key] = value;
|
map[key] = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void WriteLongPacketMap<T>(Dictionary<long, T> map, short protocolId)
|
public void WriteLongPacketMap<T>(Dictionary<long, T> map, short protocolId)
|
||||||
{
|
{
|
||||||
if ((map == null) || (map.Count == 0))
|
if ((map == null) || (map.Count == 0))
|
||||||
{
|
{
|
||||||
WriteInt(0);
|
WriteInt(0);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
IProtocolRegistration protocolRegistration = ProtocolManager.GetProtocol(protocolId);
|
IProtocolRegistration protocolRegistration = ProtocolManager.GetProtocol(protocolId);
|
||||||
WriteInt(map.Count);
|
WriteInt(map.Count);
|
||||||
foreach (var element in map)
|
foreach (var element in map)
|
||||||
{
|
{
|
||||||
WriteLong(element.Key);
|
WriteLong(element.Key);
|
||||||
protocolRegistration.Write(this, (IPacket) element.Value);
|
protocolRegistration.Write(this, (IPacket) element.Value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Dictionary<long, T> ReadLongPacketMap<T>(short protocolId)
|
public Dictionary<long, T> ReadLongPacketMap<T>(short protocolId)
|
||||||
{
|
{
|
||||||
int size = ReadInt();
|
int size = ReadInt();
|
||||||
Dictionary<long, T> map = new Dictionary<long, T>(size);
|
Dictionary<long, T> map = new Dictionary<long, T>(size);
|
||||||
if (size > 0)
|
if (size > 0)
|
||||||
{
|
{
|
||||||
IProtocolRegistration protocolRegistration = ProtocolManager.GetProtocol(protocolId);
|
IProtocolRegistration protocolRegistration = ProtocolManager.GetProtocol(protocolId);
|
||||||
for (int index = 0; index < size; index++)
|
for (int index = 0; index < size; index++)
|
||||||
{
|
{
|
||||||
var key = ReadLong();
|
var key = ReadLong();
|
||||||
var value = (T) protocolRegistration.Read(this);
|
var value = (T) protocolRegistration.Read(this);
|
||||||
map[key] = value;
|
map[key] = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return map;
|
|
||||||
}
|
return map;
|
||||||
|
}
|
||||||
|
|
||||||
public void WriteStringIntMap(Dictionary<string, int> map)
|
public void WriteStringIntMap(Dictionary<string, int> map)
|
||||||
{
|
{
|
||||||
@@ -1761,6 +1799,7 @@ namespace CsProtocol.Buffer
|
|||||||
map[key] = value;
|
map[key] = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1794,6 +1833,7 @@ namespace CsProtocol.Buffer
|
|||||||
map[key] = value;
|
map[key] = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1827,43 +1867,45 @@ namespace CsProtocol.Buffer
|
|||||||
map[key] = value;
|
map[key] = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void WriteStringPacketMap<T>(Dictionary<string, T> map, short protocolId)
|
public void WriteStringPacketMap<T>(Dictionary<string, T> map, short protocolId)
|
||||||
{
|
{
|
||||||
if ((map == null) || (map.Count == 0))
|
if ((map == null) || (map.Count == 0))
|
||||||
{
|
{
|
||||||
WriteInt(0);
|
WriteInt(0);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
IProtocolRegistration protocolRegistration = ProtocolManager.GetProtocol(protocolId);
|
IProtocolRegistration protocolRegistration = ProtocolManager.GetProtocol(protocolId);
|
||||||
WriteInt(map.Count);
|
WriteInt(map.Count);
|
||||||
foreach (var element in map)
|
foreach (var element in map)
|
||||||
{
|
{
|
||||||
WriteString(element.Key);
|
WriteString(element.Key);
|
||||||
protocolRegistration.Write(this, (IPacket) element.Value);
|
protocolRegistration.Write(this, (IPacket) element.Value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Dictionary<string, T> ReadStringPacketMap<T>(short protocolId)
|
public Dictionary<string, T> ReadStringPacketMap<T>(short protocolId)
|
||||||
{
|
{
|
||||||
int size = ReadInt();
|
int size = ReadInt();
|
||||||
Dictionary<string, T> map = new Dictionary<string, T>(size);
|
Dictionary<string, T> map = new Dictionary<string, T>(size);
|
||||||
if (size > 0)
|
if (size > 0)
|
||||||
{
|
{
|
||||||
IProtocolRegistration protocolRegistration = ProtocolManager.GetProtocol(protocolId);
|
IProtocolRegistration protocolRegistration = ProtocolManager.GetProtocol(protocolId);
|
||||||
for (int index = 0; index < size; index++)
|
for (int index = 0; index < size; index++)
|
||||||
{
|
{
|
||||||
var key = ReadString();
|
var key = ReadString();
|
||||||
var value = (T) protocolRegistration.Read(this);
|
var value = (T) protocolRegistration.Read(this);
|
||||||
map[key] = value;
|
map[key] = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return map;
|
|
||||||
}
|
return map;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
namespace CsProtocol.Buffer
|
namespace CsProtocol.Buffer
|
||||||
{
|
{
|
||||||
public class BigEndianByteBuffer : ByteBuffer
|
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
|
public interface IPacket
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
namespace CsProtocol.Buffer
|
namespace CsProtocol.Buffer
|
||||||
{
|
{
|
||||||
public interface IProtocolRegistration
|
public interface IProtocolRegistration
|
||||||
{
|
{
|
||||||
|
|||||||
File diff suppressed because it is too large.
Load diff
@@ -5,61 +5,44 @@ using CsProtocol.Buffer;
|
|||||||
namespace CsProtocol
|
namespace CsProtocol
|
||||||
{
|
{
|
||||||
// @author jaysunxiao
|
// @author jaysunxiao
|
||||||
// @version 1.0
|
// @version 3.0
|
||||||
// @since 2021-02-07 17:18
|
|
||||||
public class NormalObject : IPacket
|
public class NormalObject : IPacket
|
||||||
{
|
{
|
||||||
public byte a;
|
public byte a;
|
||||||
public byte[] aaa;
|
public byte[] aaa;
|
||||||
public short b;
|
public short b;
|
||||||
public short[] bbb;
|
|
||||||
public int c;
|
public int c;
|
||||||
public int[] ccc;
|
|
||||||
public long d;
|
public long d;
|
||||||
public long[] ddd;
|
|
||||||
public float e;
|
public float e;
|
||||||
public float[] eee;
|
|
||||||
public double f;
|
public double f;
|
||||||
public double[] fff;
|
|
||||||
public bool g;
|
public bool g;
|
||||||
public bool[] ggg;
|
|
||||||
public char h;
|
|
||||||
public char[] hhh;
|
|
||||||
public string jj;
|
public string jj;
|
||||||
public string[] jjj;
|
|
||||||
public ObjectA kk;
|
public ObjectA kk;
|
||||||
public ObjectA[] kkk;
|
|
||||||
public List<int> l;
|
public List<int> l;
|
||||||
|
public List<long> ll;
|
||||||
|
public List<ObjectA> lll;
|
||||||
public List<string> llll;
|
public List<string> llll;
|
||||||
public Dictionary<int, string> m;
|
public Dictionary<int, string> m;
|
||||||
public Dictionary<int, ObjectA> mm;
|
public Dictionary<int, ObjectA> mm;
|
||||||
public HashSet<int> s;
|
public HashSet<int> s;
|
||||||
public HashSet<string> ssss;
|
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();
|
var packet = new NormalObject();
|
||||||
packet.a = a;
|
packet.a = a;
|
||||||
packet.aaa = aaa;
|
packet.aaa = aaa;
|
||||||
packet.b = b;
|
packet.b = b;
|
||||||
packet.bbb = bbb;
|
|
||||||
packet.c = c;
|
packet.c = c;
|
||||||
packet.ccc = ccc;
|
|
||||||
packet.d = d;
|
packet.d = d;
|
||||||
packet.ddd = ddd;
|
|
||||||
packet.e = e;
|
packet.e = e;
|
||||||
packet.eee = eee;
|
|
||||||
packet.f = f;
|
packet.f = f;
|
||||||
packet.fff = fff;
|
|
||||||
packet.g = g;
|
packet.g = g;
|
||||||
packet.ggg = ggg;
|
|
||||||
packet.h = h;
|
|
||||||
packet.hhh = hhh;
|
|
||||||
packet.jj = jj;
|
packet.jj = jj;
|
||||||
packet.jjj = jjj;
|
|
||||||
packet.kk = kk;
|
packet.kk = kk;
|
||||||
packet.kkk = kkk;
|
|
||||||
packet.l = l;
|
packet.l = l;
|
||||||
|
packet.ll = ll;
|
||||||
|
packet.lll = lll;
|
||||||
packet.llll = llll;
|
packet.llll = llll;
|
||||||
packet.m = m;
|
packet.m = m;
|
||||||
packet.mm = mm;
|
packet.mm = mm;
|
||||||
@@ -71,7 +54,7 @@ namespace CsProtocol
|
|||||||
|
|
||||||
public short ProtocolId()
|
public short ProtocolId()
|
||||||
{
|
{
|
||||||
return 1161;
|
return 101;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -80,250 +63,34 @@ namespace CsProtocol
|
|||||||
{
|
{
|
||||||
public short ProtocolId()
|
public short ProtocolId()
|
||||||
{
|
{
|
||||||
return 1161;
|
return 101;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Write(ByteBuffer buffer, IPacket packet)
|
public void Write(ByteBuffer buffer, IPacket packet)
|
||||||
{
|
{
|
||||||
if (packet == null)
|
if (buffer.WritePacketFlag(packet))
|
||||||
{
|
{
|
||||||
buffer.WriteBool(false);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
buffer.WriteBool(true);
|
|
||||||
NormalObject message = (NormalObject) packet;
|
NormalObject message = (NormalObject) packet;
|
||||||
buffer.WriteByte(message.a);
|
buffer.WriteByte(message.a);
|
||||||
if ((message.aaa == null) || (message.aaa.Length == 0))
|
buffer.WriteByteArray(message.aaa);
|
||||||
{
|
|
||||||
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.WriteShort(message.b);
|
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);
|
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);
|
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);
|
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);
|
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);
|
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);
|
buffer.WriteString(message.jj);
|
||||||
if ((message.jjj == null) || (message.jjj.Length == 0))
|
ProtocolManager.GetProtocol(102).Write(buffer, message.kk);
|
||||||
{
|
buffer.WriteIntList(message.l);
|
||||||
buffer.WriteInt(0);
|
buffer.WriteLongList(message.ll);
|
||||||
}
|
buffer.WritePacketList(message.lll, 102);
|
||||||
else
|
buffer.WriteStringList(message.llll);
|
||||||
{
|
buffer.WriteIntStringMap(message.m);
|
||||||
buffer.WriteInt(message.jjj.Length);
|
buffer.WriteIntPacketMap(message.mm, 102);
|
||||||
int length24 = message.jjj.Length;
|
buffer.WriteIntSet(message.s);
|
||||||
for (int i25 = 0; i25 < length24; i25++)
|
buffer.WriteStringSet(message.ssss);
|
||||||
{
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public IPacket Read(ByteBuffer buffer)
|
public IPacket Read(ByteBuffer buffer)
|
||||||
@@ -333,204 +100,42 @@ namespace CsProtocol
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
NormalObject packet = new NormalObject();
|
NormalObject packet = new NormalObject();
|
||||||
byte result44 = buffer.ReadByte();
|
byte result0 = buffer.ReadByte();
|
||||||
packet.a = result44;
|
packet.a = result0;
|
||||||
int size47 = buffer.ReadInt();
|
var array1 = buffer.ReadByteArray();
|
||||||
byte[] result45 = new byte[size47];
|
packet.aaa = array1;
|
||||||
if (size47 > 0)
|
short result2 = buffer.ReadShort();
|
||||||
{
|
packet.b = result2;
|
||||||
for (int index46 = 0; index46 < size47; index46++)
|
int result3 = buffer.ReadInt();
|
||||||
{
|
packet.c = result3;
|
||||||
byte result48 = buffer.ReadByte();
|
long result4 = buffer.ReadLong();
|
||||||
result45[index46] = result48;
|
packet.d = result4;
|
||||||
}
|
float result5 = buffer.ReadFloat();
|
||||||
}
|
packet.e = result5;
|
||||||
packet.aaa = result45;
|
double result6 = buffer.ReadDouble();
|
||||||
short result49 = buffer.ReadShort();
|
packet.f = result6;
|
||||||
packet.b = result49;
|
bool result7 = buffer.ReadBool();
|
||||||
int size52 = buffer.ReadInt();
|
packet.g = result7;
|
||||||
short[] result50 = new short[size52];
|
string result8 = buffer.ReadString();
|
||||||
if (size52 > 0)
|
packet.jj = result8;
|
||||||
{
|
ObjectA result9 = (ObjectA) ProtocolManager.GetProtocol(102).Read(buffer);
|
||||||
for (int index51 = 0; index51 < size52; index51++)
|
packet.kk = result9;
|
||||||
{
|
var list10 = buffer.ReadIntList();
|
||||||
short result53 = buffer.ReadShort();
|
packet.l = list10;
|
||||||
result50[index51] = result53;
|
var list11 = buffer.ReadLongList();
|
||||||
}
|
packet.ll = list11;
|
||||||
}
|
var list12 = buffer.ReadPacketList<ObjectA>(102);
|
||||||
packet.bbb = result50;
|
packet.lll = list12;
|
||||||
int result54 = buffer.ReadInt();
|
var list13 = buffer.ReadStringList();
|
||||||
packet.c = result54;
|
packet.llll = list13;
|
||||||
int size57 = buffer.ReadInt();
|
var map14 = buffer.ReadIntStringMap();
|
||||||
int[] result55 = new int[size57];
|
packet.m = map14;
|
||||||
if (size57 > 0)
|
var map15 = buffer.ReadIntPacketMap<ObjectA>(102);
|
||||||
{
|
packet.mm = map15;
|
||||||
for (int index56 = 0; index56 < size57; index56++)
|
var set16 = buffer.ReadIntSet();
|
||||||
{
|
packet.s = set16;
|
||||||
int result58 = buffer.ReadInt();
|
var set17 = buffer.ReadStringSet();
|
||||||
result55[index56] = result58;
|
packet.ssss = set17;
|
||||||
}
|
|
||||||
}
|
|
||||||
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;
|
|
||||||
return packet;
|
return packet;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,8 +5,7 @@ using CsProtocol.Buffer;
|
|||||||
namespace CsProtocol
|
namespace CsProtocol
|
||||||
{
|
{
|
||||||
// @author jaysunxiao
|
// @author jaysunxiao
|
||||||
// @version 1.0
|
// @version 3.0
|
||||||
// @since 2017 10.12 15:39
|
|
||||||
public class ObjectA : IPacket
|
public class ObjectA : IPacket
|
||||||
{
|
{
|
||||||
public int a;
|
public int a;
|
||||||
@@ -25,7 +24,7 @@ namespace CsProtocol
|
|||||||
|
|
||||||
public short ProtocolId()
|
public short ProtocolId()
|
||||||
{
|
{
|
||||||
return 1116;
|
return 102;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -34,35 +33,19 @@ namespace CsProtocol
|
|||||||
{
|
{
|
||||||
public short ProtocolId()
|
public short ProtocolId()
|
||||||
{
|
{
|
||||||
return 1116;
|
return 102;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Write(ByteBuffer buffer, IPacket packet)
|
public void Write(ByteBuffer buffer, IPacket packet)
|
||||||
{
|
{
|
||||||
if (packet == null)
|
if (buffer.WritePacketFlag(packet))
|
||||||
{
|
{
|
||||||
buffer.WriteBool(false);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
buffer.WriteBool(true);
|
|
||||||
ObjectA message = (ObjectA) packet;
|
ObjectA message = (ObjectA) packet;
|
||||||
buffer.WriteInt(message.a);
|
buffer.WriteInt(message.a);
|
||||||
if ((message.m == null) || (message.m.Count == 0))
|
buffer.WriteIntStringMap(message.m);
|
||||||
{
|
ProtocolManager.GetProtocol(103).Write(buffer, message.objectB);
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public IPacket Read(ByteBuffer buffer)
|
public IPacket Read(ByteBuffer buffer)
|
||||||
@@ -72,22 +55,12 @@ namespace CsProtocol
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
ObjectA packet = new ObjectA();
|
ObjectA packet = new ObjectA();
|
||||||
int result3 = buffer.ReadInt();
|
int result0 = buffer.ReadInt();
|
||||||
packet.a = result3;
|
packet.a = result0;
|
||||||
int size5 = buffer.ReadInt();
|
var map1 = buffer.ReadIntStringMap();
|
||||||
var result4 = new Dictionary<int, string>(size5);
|
packet.m = map1;
|
||||||
if (size5 > 0)
|
ObjectB result2 = (ObjectB) ProtocolManager.GetProtocol(103).Read(buffer);
|
||||||
{
|
packet.objectB = result2;
|
||||||
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;
|
|
||||||
return packet;
|
return packet;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,8 +5,7 @@ using CsProtocol.Buffer;
|
|||||||
namespace CsProtocol
|
namespace CsProtocol
|
||||||
{
|
{
|
||||||
// @author jaysunxiao
|
// @author jaysunxiao
|
||||||
// @version 1.0
|
// @version 3.0
|
||||||
// @since 2017 10.12 15:39
|
|
||||||
public class ObjectB : IPacket
|
public class ObjectB : IPacket
|
||||||
{
|
{
|
||||||
public bool flag;
|
public bool flag;
|
||||||
@@ -21,7 +20,7 @@ namespace CsProtocol
|
|||||||
|
|
||||||
public short ProtocolId()
|
public short ProtocolId()
|
||||||
{
|
{
|
||||||
return 1117;
|
return 103;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -30,17 +29,15 @@ namespace CsProtocol
|
|||||||
{
|
{
|
||||||
public short ProtocolId()
|
public short ProtocolId()
|
||||||
{
|
{
|
||||||
return 1117;
|
return 103;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Write(ByteBuffer buffer, IPacket packet)
|
public void Write(ByteBuffer buffer, IPacket packet)
|
||||||
{
|
{
|
||||||
if (packet == null)
|
if (buffer.WritePacketFlag(packet))
|
||||||
{
|
{
|
||||||
buffer.WriteBool(false);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
buffer.WriteBool(true);
|
|
||||||
ObjectB message = (ObjectB) packet;
|
ObjectB message = (ObjectB) packet;
|
||||||
buffer.WriteBool(message.flag);
|
buffer.WriteBool(message.flag);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,8 +5,7 @@ using CsProtocol.Buffer;
|
|||||||
namespace CsProtocol
|
namespace CsProtocol
|
||||||
{
|
{
|
||||||
// @author jaysunxiao
|
// @author jaysunxiao
|
||||||
// @version 1.0
|
// @version 3.0
|
||||||
// @since 2021-03-27 15:18
|
|
||||||
public class SimpleObject : IPacket
|
public class SimpleObject : IPacket
|
||||||
{
|
{
|
||||||
public int c;
|
public int c;
|
||||||
@@ -23,7 +22,7 @@ namespace CsProtocol
|
|||||||
|
|
||||||
public short ProtocolId()
|
public short ProtocolId()
|
||||||
{
|
{
|
||||||
return 1163;
|
return 104;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -32,17 +31,15 @@ namespace CsProtocol
|
|||||||
{
|
{
|
||||||
public short ProtocolId()
|
public short ProtocolId()
|
||||||
{
|
{
|
||||||
return 1163;
|
return 104;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Write(ByteBuffer buffer, IPacket packet)
|
public void Write(ByteBuffer buffer, IPacket packet)
|
||||||
{
|
{
|
||||||
if (packet == null)
|
if (buffer.WritePacketFlag(packet))
|
||||||
{
|
{
|
||||||
buffer.WriteBool(false);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
buffer.WriteBool(true);
|
|
||||||
SimpleObject message = (SimpleObject) packet;
|
SimpleObject message = (SimpleObject) packet;
|
||||||
buffer.WriteInt(message.c);
|
buffer.WriteInt(message.c);
|
||||||
buffer.WriteBool(message.g);
|
buffer.WriteBool(message.g);
|
||||||
|
|||||||
@@ -50,20 +50,20 @@ namespace CsProtocol
|
|||||||
return protocol;
|
return protocol;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void Write(ByteBuffer byteBuffer, IPacket packet)
|
public static void Write(ByteBuffer buffer, IPacket packet)
|
||||||
{
|
{
|
||||||
var protocolId = packet.ProtocolId();
|
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();
|
var protocolId = buffer.ReadShort();
|
||||||
return GetProtocol(protocolId).Read(byteBuffer);
|
return GetProtocol(protocolId).Read(buffer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user