Abstract Classes

14 views
Skip to first unread message

J.C.

unread,
Mar 21, 2017, 2:02:19 PM3/21/17
to MessagePack Users
Hello, I have been trying to use MsgPack with Unity but I am running into so many issues with deserialization.

These objects are simple enough and serialize but when trying to deserialize them they are null.. any help would be greatly appreciated.

A simple chat message serialized (shown here as a base64 encoded byte array) This was serialized by MsgPAck but I can deserialize it! HELP
l6ROb25lwNJYf+5npHRlc3TRE6ywQ29tbWFuZGVyOTQ2NDA1NKZHbG9iYWw=


The class definitions are as follows...


[Serializable]
    public enum MessageType
    {
        Authentication,
        ChatMessage
    }
[Serializable]
    public enum RoomType
    {
        Global,
        Alliance,
        Private
    }

[Serializable]
    public class CommServerAuth : CommBase
    {
        public override MessageType MessageType
        {
            get { return MessageType.Authentication; }
        }

public int UserId;
public string Token;
    }


[Serializable]
    public class ChatMessage_org : CommBase
    {
        public override MessageType MessageType
        {
            get { return MessageType.ChatMessage; }
        }

public RoomType Room;
public string PlayerName;
public long MessageDateTime;
public string AllianceName;
public string MessageText;
    }

J.C.

unread,
Mar 21, 2017, 2:51:40 PM3/21/17
to MessagePack Users
Well I found out that the Unity MsgPack code is what seems to be failing. If I execute the following code on the Unity code it crashes but if I run it on the 3.5 version it seems to be fine.

Any suggestions?

    public void Test()
    {
        ChatMessage c = new ChatMessage();
        c.AllianceName = "A1";
        c.LoginToken = "sometoken";
        c.MessageText = "hello world";        
        MPEncap m = new MPEncap();
        var x = m.Serialize<ChatMessage>(c);
        var y = m.Deserialize<ChatMessage>(x);  
Reply all
Reply to author
Forward
0 new messages