Netty Protostuff到Unity protobuf-net:“源数据0中的无效字段”

时间:2016-11-04 09:28:28

标签: c# unity3d netty protostuff

我创建了一个java服务器基础Netty并使用Protostuff处理数据,但是当我在游戏客户端基础统一中接收数据然后反序列化它,但是抛出错误:"源数据0中的无效字段"。我该如何解决?

Java代码:

private Schema<SocketModel> schema=RuntimeSchema.getSchema(SocketModel.class);
LinkedBuffer buffer = LinkedBuffer.allocate(1024);
    byte[] data = ProtobufIOUtil.toByteArray(message, schema, buffer);  
    ByteBuf buf = Unpooled.copiedBuffer(CoderUtil.IntToBytes(data.length),data); 

out.writeBytes(BUF);

C#代码:

 private SocketModel DeSerial(byte[] msg)
{
    using (MemoryStream ms = new MemoryStream(msg))
    {

            SocketModel socketModel = Serializer.Deserialize<SocketModel>(ms);
            return socketModel;
    }
}

0 个答案:

没有答案