Giter Site home page Giter Site logo

Comments (13)

deniszykov avatar deniszykov commented on August 25, 2024

Hi, probably you have different BCL assemblies on serialization and de-serialization endpoints. Are you using .NET Core or some WinRT runtime?

from msgpack-unity3d.

Janry avatar Janry commented on August 25, 2024

Unity (5.6.2f1) Project Settings for ios build:
Scripting Backend: IL2CPP
Api Compatibility Level: .NET 2.0

Server:
.NET Framework 3.5

from msgpack-unity3d.

deniszykov avatar deniszykov commented on August 25, 2024

Hmmm.
Could you provide MessagePack serialized data for test? The same which gives you exception above.

from msgpack-unity3d.

deniszykov avatar deniszykov commented on August 25, 2024

Also could you try this commit 268ef86 (last one in this repository)?

from msgpack-unity3d.

Janry avatar Janry commented on August 25, 2024

So, about serialized data for the test.

ErrorSystem.Exception: Can`t parse packet, length:138 new byte[] { 131, 165, 95, 116, 121, 112, 101, 187, 80, 114, 111, 116, 111, 99, 111, 108, 46, 84, 101, 115, 116, 73, 110, 102, 111, 44, 32, 80, 114, 111, 116, 111, 99, 111, 108, 163, 85, 73, 68, 217, 36, 101, 52, 56, 51, 52, 54, 99, 99, 45, 101, 54, 52, 49, 45, 52, 102, 55, 52, 45, 57, 99, 55, 100, 45, 51, 57, 52, 54, 54, 51, 99, 102, 55, 56, 55, 51, 171, 68, 101, 99, 111, 114, 97, 116, 105, 111, 110, 115, 145, 130, 165, 95, 116, 121, 112, 101, 184, 80, 114, 111, 116, 111, 99, 111, 108, 46, 68, 101, 99, 111, 114, 44, 32, 80, 114, 111, 116, 111, 99, 111, 108, 168, 80, 111, 115, 105, 116, 105, 111, 110, 130, 161, 88, 0, 161, 89, 13 } ---> System.Runtime.Serialization.SerializationException: Failed to read value for member 'Decorations' of 'TestInfo' type.

public class Point<TCoord> where TCoord : struct
{
    public TCoord X;
    public TCoord Y;
}

public class Decor
{
    public Point<byte> Position;
}

public class TestInfo : ServerPacket
{
    public Decor[] Decorations;
}

Decor and TestInfo have a Protocol namespace and Point - Protocol.Types.

{
"$type": "Protocol.TestInfo, Protocol",
"Decorations": [
{
"$type": "Protocol.Decor, Protocol",
"Position": {
"$type": "Protocol.Types.Point`1[[System.Byte, mscorlib]], Protocol",
"X": 0,
"Y": 13
}
}
]
}

from msgpack-unity3d.

deniszykov avatar deniszykov commented on August 25, 2024

Thanks for test data! I will check it.

from msgpack-unity3d.

deniszykov avatar deniszykov commented on August 25, 2024

Actually in your test data there is no type information for Point type.
Here is ASCII: "??_type?Protocol.TestInfo, Protocol?UID?$e48346cc-e641-4f74-9c7d-394663cf7873?Decorations???_type?Protocol.Decor, Protocol?Position??X\u0000?Y\u000D".

As workaround you could suppress all type information in your messages until inheritance or serialization by the base type (like object values in dictionaries) being involved.
This will be faster and safer from security concern.

MsgPack.Serialize(... SerializationOptions.SuppressTypeInformation);

from msgpack-unity3d.

Janry avatar Janry commented on August 25, 2024

There is no type information for Point type because I used custom serializer, I think.

Here's the example which gives the exception too.

public class Decoration
{
    public int BuildingId;
    public Point<byte> Position;
}

namespace Protocol.CityBuilder

[131][165]_type[217])Protocol.CityBuilder.Decoration, Protocol[170]BuildingId[209][1][245][168]Position[131][165]_type[217]9Protocol.Types.Point`1[[System.Byte, mscorlib]], Protocol[161]X[0][161]Y[13]

{131, 165, 95, 116, 121, 112, 101, 217, 41, 80, 114, 111, 116, 111, 99, 111, 108, 46, 67, 105, 116, 121, 66, 117, 105, 108, 100, 101, 114, 46, 68, 101, 99, 111, 114, 97, 116, 105, 111, 110, 44, 32, 80, 114, 111, 116, 111, 99, 111, 108, 170, 66, 117, 105, 108, 100, 105, 110, 103, 73, 100, 209, 1, 245, 168, 80, 111, 115, 105, 116, 105, 111, 110, 131, 165, 95, 116, 121, 112, 101, 217, 57, 80, 114, 111, 116, 111, 99, 111, 108, 46, 84, 121, 112, 101, 115, 46, 80, 111, 105, 110, 116, 96, 49, 91, 91, 83, 121, 115, 116, 101, 109, 46, 66, 121, 116, 101, 44, 32, 109, 115, 99, 111, 114, 108, 105, 98, 93, 93, 44, 32, 80, 114, 111, 116, 111, 99, 111, 108, 161, 88, 0, 161, 89, 13}

from msgpack-unity3d.

deniszykov avatar deniszykov commented on August 25, 2024

I can't repoduce it on iOS and IL2CPP. Are you sure Packet types are not stripped ('Protocol' assembly is specified in link.xml) and strong linked (has references) to Unity's project assembles?

from msgpack-unity3d.

Janry avatar Janry commented on August 25, 2024

'Protocol' assembly didn't specify in link.xml. I have problem just with generic type Point. I will try it and write about a result.

from msgpack-unity3d.

Janry avatar Janry commented on August 25, 2024

Should I use your last commit for the check is it stable changes?

from msgpack-unity3d.

deniszykov avatar deniszykov commented on August 25, 2024

from msgpack-unity3d.

Janry avatar Janry commented on August 25, 2024

May you show the example how should correctly Packet types link with Unity project? Also how correctly build dll with your last commit for Unity project?

Just add info into link.xml like this?

<linker>
  <assembly fullname="Protocol">
    <type fullname="Protocol.Types.Point" preserve="all" />
    <namespace fullname="Protocol.Types" preserve="all" />
  </assembly>
</linker>

from msgpack-unity3d.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.