Proto文件更新
This commit is contained in:
parent
c24fd38f6c
commit
9072256301
28
xiaofang/Assets/comm/Proto/ProtoBufffer.cs
Normal file
28
xiaofang/Assets/comm/Proto/ProtoBufffer.cs
Normal 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();
|
||||
}
|
||||
}
|
||||
|
11
xiaofang/Assets/comm/Proto/ProtoBufffer.cs.meta
Normal file
11
xiaofang/Assets/comm/Proto/ProtoBufffer.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: cbf21bdbee5a320489df7092ce24d9a7
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -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;
|
||||
|
||||
//
|
||||
|
Loading…
Reference in New Issue
Block a user