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