Proto文件更新

This commit is contained in:
huyulong 2024-11-29 15:22:51 +08:00
parent c24fd38f6c
commit 9072256301
3 changed files with 40 additions and 1 deletions

View File

@ -0,0 +1,28 @@
using Google.Protobuf;
using System;
public class ProtoBufffer
{
public static byte[] Serialize(IMessage message)
{
return message.ToByteArray();
}
public static T DeSerialize<T>(byte[] packet) where T : IMessage, new()
{
IMessage message = new T();
try
{
return (T)message.Descriptor.Parser.ParseFrom(packet);
}
catch (System.Exception e)
{
throw;
}
}
internal static T DeSerialize<T>(ByteString data)
{
throw new NotImplementedException();
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: cbf21bdbee5a320489df7092ce24d9a7
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -300,7 +300,7 @@ public class test : MonoBehaviour
case "hall.BroadcastMessage":
UserJoinResponse userJoinResponse = ProtoBufffer.DeSerialize<UserJoinResponse>(bytes);
Debug.Log("玩家昵称:" + userJoinResponse.NickName + ",房间:" + userJoinResponse.RoomId.ToString() + ",用户角色"+ userJoinResponse.RoleName);
userJoinResponse.
break;
//