Hashtable vs Dictionary<byte,object> in EventData constructo

Options
escjosh
edited July 2012 in Photon Server
Does the following seem correct? I've simplified the dictionary data, but my actual case is very similar.

var params = new Dictionary<byte,object> { {0, 0}, {1, 1}, {2, 2} }
var ev = new EventData( eventCode, params );
→ ev.Parameters.Count == 3

var params = new Hashtable { {0, 0}, {1, 1}, {2, 2} }
var ev = new EventData( eventCode, params );
→ ev.Parameters.Count == 0

Comments

  • escjosh
    Options
    Sending Hashtables back in OperationResponses works fine. It seems to just be EventData. Or maybe there's something special about the Hashtable that's causing the serialization to fail?
  • escjosh
    Options
    In the relevant OperationResponses, I send something like this (an array of dictionaries):
    new OperationResponse( 0, new MyResponse { Info = { new Dictionary<byte,object>[] {...} } } )

    On the client (Unity), I have to cast it to IDictionary[] - casting to either Hashtable or Dictionary<byte,object> throws an invalid cast exception. GetType().ToString() just says IDictionary.


    In the relevant EventDatas, I send something like this:
    new EventData( 0, new Dictionary<byte,object> {...} )
    And it comes through as that same type, due to EventData.Parameters being that type.


    This seemed like a contradiction until I realized that my OperationResponses are using the "object datacontract" constructor form, while my EventDatas are using the "Dictionary<byte,object> parameters" constructor.

    So I suppose that means that serializing "(object)(new Dictionary<byte,object>{...})" is not the same as directly serializing the Dictionary<byte,object>{...}? Or that there's some special code in the two constructors that sets the client's deserialization method, and it doesn't work the same?

    In any case, I think I understand the behavior now even if I don't understand exactly why. :D
  • Kaiserludi
    Options
    escjosh wrote:
    an array of dictionaries
    Thats the cause of your problems: arrays of Dictionaries are not yet supported on server side in the current relase. They will be supported (including support for jagged Dictionary arrays) with the next server version, which will get available within the next couple of days (we will also update the cloud to that version then).
    However the currently released clients don't support arrays of Dictionaries either. The next release of the C, C++ and objective C clients will come with Dictionary array support, but I don't know, if the next C# client release will already support them. You wil have to wait for a response from Tobias therefor.

    As a workaround you can use arrays of Hashtables for now, which are already supported on client- and server-side for long time.

    PS: I should mention, that Dictionaries as values of Dictionaries are also not supported by the server yet (however, Dictionaries as values of Hashtables, Hashtables as values of Hashtables and Hashtables as values of Dictionaries are) and I don't know, if support for them will already been included in the next release.
  • escjosh
    Options
    Excellent, thanks. That makes sense. I'm looking forward to the next release, it sounds like you've made a lot of improvements.
  • Kaiserludi
    Options
    It will finally be the first server version, that will officially be called 3.0 without a "Release Candidate" in its name, so yes, you can expect a few improvements :)
  • Kaiserludi
    Options
    Kaiserludi wrote:
    PS: I should mention, that Dictionaries as values of Dictionaries are also not supported by the server yet (however, Dictionaries as values of Hashtables, Hashtables as values of Hashtables and Hashtables as values of Dictionaries are) and I don't know, if support for them will already been included in the next release.
    Update:
    Yes, that fix will be included in the 3.0 final :)

    PS: The 3.0 final will most probably get released this week 8-)