LoadBalancingApi can not serialize an array?
zhuchun
✭
Hi, in order to combine packet as much as possible, I want to wrap my data into Dictionary[] and then send it to the server. But Unity Editor throws IndexOurOfRangeExceptions while trying to serialize it. Is that a bug or custom data has to be sent as a Hashtable?
Snapshot:
-----
CustomData:
-----
Snapshot:
-----
CustomData:
var inputs= new List <Dictionary <byte,object>>();
foreach (var input in e.inputBuffer.Cached)
{
inputs.Add(input.ToDictionary());
}
var customDataToBeSent = inputs.ToArray();
-----
0
Comments
-
0
-
Hi.
To clarify for future readers, who use other clients:
Actually sending Arrays of Dictionaries is supported on the server and in some clients (I know for sure that it is supported in the C++ and objective C clients - @vadim should be able to tell about the others), just not in the C# client.1 -
Thank you.
In that Serialization in Photon page it said
So I thought Dictionary is OK Does it mean collection array is not supported in the C# LoadBalacingApi?
array (array of type T, T[])
T-type can be any of the types listed in this table except byte.
Is there any supported way to send data in batch?0 -
>Does it mean collection array is not supported in the C# LoadBalacingApi?
Yes, exactly. Current version for some reason does not support this feature
>Is there any supported way to send data in batch?
please ask in a corresponding forum section. I would suggest using a dictionary or hashtable
best,
ilya0 -
Hi @zhuchun.
I am not too familiar with the C# Client myself, so I am not 100% sure that this will work, but what you could also try is casting your array of Dictionaries into an array of Objects. Object arrays are treated differently by Photons serialization code than normal arrays. For the former the type info is written not once per array, but once per element, as each element could be of a different type. Due to this difference there is a good chance that sending Object arrays with Dictionary elements works in the current C# clients.1