mirror of
https://github.com/tiennm99/zfoo.git
synced 2026-06-09 10:14:39 +00:00
feat[net]: await grammar for unity
This commit is contained in:
@@ -563,7 +563,7 @@ namespace CsProtocol.Buffer
|
||||
return Encoding.UTF8.GetString(value, 0, value.Length);
|
||||
}
|
||||
|
||||
public bool WritePacketFlag(IPacket packet)
|
||||
public bool WritePacketFlag(IProtocol packet)
|
||||
{
|
||||
bool flag = packet == null;
|
||||
WriteBool(!flag);
|
||||
@@ -871,7 +871,7 @@ namespace CsProtocol.Buffer
|
||||
int length = array.Length;
|
||||
for (int index = 0; index < length; index++)
|
||||
{
|
||||
protocolRegistration.Write(this, (IPacket) array[index]);
|
||||
protocolRegistration.Write(this, (IProtocol) array[index]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1193,7 +1193,7 @@ namespace CsProtocol.Buffer
|
||||
int length = list.Count;
|
||||
for (int index = 0; index < length; index++)
|
||||
{
|
||||
protocolRegistration.Write(this, (IPacket) list[index]);
|
||||
protocolRegistration.Write(this, (IProtocol) list[index]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1474,7 +1474,7 @@ namespace CsProtocol.Buffer
|
||||
WriteInt(set.Count);
|
||||
foreach (var element in set)
|
||||
{
|
||||
protocolRegistration.Write(this, (IPacket) element);
|
||||
protocolRegistration.Write(this, (IProtocol) element);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1611,7 +1611,7 @@ namespace CsProtocol.Buffer
|
||||
foreach (var element in map)
|
||||
{
|
||||
WriteInt(element.Key);
|
||||
protocolRegistration.Write(this, (IPacket) element.Value);
|
||||
protocolRegistration.Write(this, (IProtocol) element.Value);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1750,7 +1750,7 @@ namespace CsProtocol.Buffer
|
||||
foreach (var element in map)
|
||||
{
|
||||
WriteLong(element.Key);
|
||||
protocolRegistration.Write(this, (IPacket) element.Value);
|
||||
protocolRegistration.Write(this, (IProtocol) element.Value);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1889,7 +1889,7 @@ namespace CsProtocol.Buffer
|
||||
foreach (var element in map)
|
||||
{
|
||||
WriteString(element.Key);
|
||||
protocolRegistration.Write(this, (IPacket) element.Value);
|
||||
protocolRegistration.Write(this, (IProtocol) element.Value);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1915,7 +1915,7 @@ namespace CsProtocol.Buffer
|
||||
public void WritePacket<T>(T packet, short protocolId)
|
||||
{
|
||||
IProtocolRegistration protocolRegistration = ProtocolManager.GetProtocol(protocolId);
|
||||
protocolRegistration.Write(this, (IPacket) packet);
|
||||
protocolRegistration.Write(this, (IProtocol) packet);
|
||||
}
|
||||
|
||||
public T ReadPacket<T>(short protocolId)
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
namespace CsProtocol.Buffer
|
||||
{
|
||||
public interface IPacket
|
||||
public interface IProtocol
|
||||
{
|
||||
short ProtocolId();
|
||||
}
|
||||
@@ -4,9 +4,9 @@
|
||||
{
|
||||
short ProtocolId();
|
||||
|
||||
void Write(ByteBuffer buffer, IPacket packet);
|
||||
void Write(ByteBuffer buffer, IProtocol packet);
|
||||
|
||||
IPacket Read(ByteBuffer buffer);
|
||||
IProtocol Read(ByteBuffer buffer);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -50,7 +50,7 @@ namespace CsProtocol
|
||||
return protocol;
|
||||
}
|
||||
|
||||
public static void Write(ByteBuffer buffer, IPacket packet)
|
||||
public static void Write(ByteBuffer buffer, IProtocol packet)
|
||||
{
|
||||
var protocolId = packet.ProtocolId();
|
||||
// 写入协议号
|
||||
@@ -60,7 +60,7 @@ namespace CsProtocol
|
||||
GetProtocol(protocolId).Write(buffer, packet);
|
||||
}
|
||||
|
||||
public static IPacket Read(ByteBuffer buffer)
|
||||
public static IProtocol Read(ByteBuffer buffer)
|
||||
{
|
||||
var protocolId = buffer.ReadShort();
|
||||
return GetProtocol(protocolId).Read(buffer);
|
||||
|
||||
@@ -5,7 +5,7 @@ using CsProtocol.Buffer;
|
||||
namespace CsProtocol
|
||||
{
|
||||
{}
|
||||
public class {} : IPacket
|
||||
public class {} : IProtocol
|
||||
{
|
||||
{}
|
||||
|
||||
@@ -31,7 +31,7 @@ namespace CsProtocol
|
||||
return {};
|
||||
}
|
||||
|
||||
public void Write(ByteBuffer buffer, IPacket packet)
|
||||
public void Write(ByteBuffer buffer, IProtocol packet)
|
||||
{
|
||||
if (buffer.WritePacketFlag(packet))
|
||||
{
|
||||
@@ -41,7 +41,7 @@ namespace CsProtocol
|
||||
{}
|
||||
}
|
||||
|
||||
public IPacket Read(ByteBuffer buffer)
|
||||
public IProtocol Read(ByteBuffer buffer)
|
||||
{
|
||||
if (!buffer.ReadBool())
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user