Dictionary deserialization error
Options
Hi all! Sorry for my English, my main language is Russian..
I have a problem with sending Dictionary.
Can i send from server to client (as response) this dictionary ? :
public Dictionary<int, byte[][]> ObjectsIDNet { get; private set; }
This is Dictionary of byte array of byte array.
I need just send my class. But i cand send as value my class. Ex.
Dictionary<int,GameObjectNet> , because photon don't know how to serialize GameObjectNet.
And i'm just converted all variables of my class to byte array of byte array. myArray[0][0] - first value - just byte number
myArray[1] - string... This is just example of how looks my variables in byte.
And when i'm sending response , on server all is ok (in log no error), but then response arive to client there is a error:
How i can send my dictionary of my class? Please help, i don't know what i need to do...
I have a problem with sending Dictionary.
Can i send from server to client (as response) this dictionary ? :
public Dictionary<int, byte[][]> ObjectsIDNet { get; private set; }
This is Dictionary of byte array of byte array.
I need just send my class. But i cand send as value my class. Ex.
Dictionary<int,GameObjectNet> , because photon don't know how to serialize GameObjectNet.
And i'm just converted all variables of my class to byte array of byte array. myArray[0][0] - first value - just byte number
myArray[1] - string... This is just example of how looks my variables in byte.
And when i'm sending response , on server all is ok (in log no error), but then response arive to client there is a error:
-
SystemException: deserialize(): 10
ExitGames.Client.Photon.Protocol.GetTypeOfCode (Byte typeCode)
ExitGames.Client.Photon.Protocol.CreateArrayByType (Byte arrayType, Int16 length)
ExitGames.Client.Photon.Protocol.DeserializeArray (System.IO.MemoryStream din)
ExitGames.Client.Photon.Protocol.Deserialize (System.IO.MemoryStream din, Byte type)
ExitGames.Client.Photon.Protocol.DeserializeDictionary (System.IO.MemoryStream din)
ExitGames.Client.Photon.Protocol.Deserialize (System.IO.MemoryStream din, Byte type)
ExitGames.Client.Photon.Protocol.DeserializeParameterTable (System.IO.MemoryStream memoryStream)
ExitGames.Client.Photon.Protocol.DeserializeOperationResponse (System.IO.MemoryStream memoryStream)
ExitGames.Client.Photon.PeerBase.DeserializeMessageAndCallback (System.Byte[] inBuff)
ExitGames.Client.Photon.EnetPeer.DispatchIncomingCommands ()
ExitGames.Client.Photon.PhotonPeer.DispatchIncomingCommands ()
ExitGames.Client.Photon.PhotonPeer.Service ()
PhotonServer.Update () (at Assets/Scripts/Network/PhotonServer.cs:48)
How i can send my dictionary of my class? Please help, i don't know what i need to do...
0
Comments
-
Anybody can reply?0
-
Hi robertono.
Sorry for the late response.
Dictionary<int, GameObjectNet> is not supported out of the box, so to get that working you would have to register GameObjectNet as a custom type both on Photon server and on all Photon client platforms, that you want to support. This would mean providing Photon with functions for serializing and deserializing instances of that class.
Dictionary<int, byte[][]> is supported by Photon on the server side and on at least some of the client platforms. I know that it works just fine with the C++ clients (you could even have a jagged Dictionary array as value type of a jagged Dictionary array), but telling from your call stack you are using it with the C# clients and apparently that doesn't seem to work.
I will point my colleague Tobias, who is handling the C# clients, to this thread.0 -
My problem is solved: I just converted my dictionary<int,GameObjectNet> to
byte [] [] []
All works fine.0 -
Obviously, there is an incompatibility between client and server. Internally, it's actually pretty complicated to send those more complex Dictionaries.
I'm glad you found a workaround. Potentially, this is even leaner than the original Dictionary, so I hope you can go on with this.0