protobuff 添加程序集引用 和修改使用MergeFromEx
This commit is contained in:
parent
ec94778778
commit
588c8850ea
@ -10,7 +10,8 @@
|
||||
"StoicGooseUnity",
|
||||
"Unity.InputSystem",
|
||||
"AxiNSApi",
|
||||
"Unity.InputSystem.Switch"
|
||||
"Unity.InputSystem.Switch",
|
||||
"Google.Protobuf"
|
||||
],
|
||||
"includePlatforms": [],
|
||||
"excludePlatforms": [],
|
||||
|
||||
@ -8,6 +8,7 @@ namespace AxibugEmuOnline.Client.Common
|
||||
public static class ProtoBufHelper
|
||||
{
|
||||
private static ProtobufferMsgPool _msgPool = new ProtobufferMsgPool();
|
||||
static CodedInputStream codedInputStream = new CodedInputStream();
|
||||
|
||||
public static void RentSerizlizeData(IMessage msg, out byte[] data, out int usedlength)
|
||||
{
|
||||
@ -28,14 +29,17 @@ namespace AxibugEmuOnline.Client.Common
|
||||
{
|
||||
var msgType = typeof(T);
|
||||
object msg = _msgPool.Get(msgType);
|
||||
((IMessage)msg).MergeFrom(bytes);
|
||||
//((IMessage)msg).MergeFrom(bytes);
|
||||
((IMessage)msg).MergeFromEx(codedInputStream, bytes, 0, bytes.Length);
|
||||
return (T)msg;
|
||||
}
|
||||
|
||||
public static IMessage DeSerizlizeFromPool(byte[] bytes, Type protoType)
|
||||
{
|
||||
var msgType = protoType;
|
||||
object msg = _msgPool.Get(msgType);
|
||||
((IMessage)msg).MergeFrom(bytes);
|
||||
//((IMessage)msg).MergeFrom(bytes);
|
||||
((IMessage)msg).MergeFromEx(codedInputStream, bytes, 0, bytes.Length);
|
||||
return (IMessage)msg;
|
||||
}
|
||||
public static void ReleaseToPool(IMessage msg)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user