您最多选择25个主题
主题必须以中文或者字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
30 行
940 B
30 行
940 B
namespace Unity.Netcode
|
|
{
|
|
internal struct NamedMessage : INetworkMessage
|
|
{
|
|
public int Version => 0;
|
|
|
|
public ulong Hash;
|
|
public FastBufferWriter SendData;
|
|
|
|
private FastBufferReader m_ReceiveData;
|
|
|
|
public unsafe void Serialize(FastBufferWriter writer, int targetVersion)
|
|
{
|
|
writer.WriteValueSafe(Hash);
|
|
writer.WriteBytesSafe(SendData.GetUnsafePtr(), SendData.Length);
|
|
}
|
|
|
|
public bool Deserialize(FastBufferReader reader, ref NetworkContext context, int receivedMessageVersion)
|
|
{
|
|
reader.ReadValueSafe(out Hash);
|
|
m_ReceiveData = reader;
|
|
return true;
|
|
}
|
|
|
|
public void Handle(ref NetworkContext context)
|
|
{
|
|
((NetworkManager)context.SystemOwner).CustomMessagingManager.InvokeNamedMessage(Hash, context.SenderId, m_ReceiveData, context.SerializedHeaderSize);
|
|
}
|
|
}
|
|
}
|