Operation Response - Send Hashtable

rofni
edited May 2011 in Photon Server
Hi

I have problems with sending arrays to the client.
ERROR UniverseQ_Libs.ServerApp - System.IO.InvalidDataException: Arrays of type 'System.Object' are not supported.
   at Photon.SocketServer.Rpc.Protocols.GpBinaryByte.GpBinaryByteWriter.WriteArray(IBinaryWriter writer, IList serObject)
   at Photon.SocketServer.Rpc.Protocols.GpBinaryByte.GpBinaryByteWriter.Write(IBinaryWriter writer, Object value, Boolean setType)
   at Photon.SocketServer.Rpc.Protocols.GpBinaryByte.GpBinaryByteProtocol.SerializeOperationResponseData(Stream stream, OperationResponse operationResponse)
   at Photon.SocketServer.Rpc.Protocols.GpBinaryByte.GpBinaryByteProtocol.SerializeOperationResponse(OperationResponse operationResponse)
   at Photon.SocketServer.PhotonPeer.SendOperationResponse(OperationResponse operationResponse)
   at Photon.SocketServer.Concurrency.ActionQueue.ExecuteAction(Action action)

Whats the best way to send a hashtable from the server to the client ?
I was thinking to serialize it to bytes and send it then or maybe i'm wrong ?

Thanks

Rofni

Comments

  • The problem is not the hashtable, it's what's in it.
    The error says it can't serialize an array of objects.
    If you want to send custom types convert them to a byte array or a hashtable first.
  • Boris wrote:
    The problem is not the hashtable, it's what's in it.
    The error says it can't serialize an array of objects.
    If you want to send custom types convert them to a byte array or a hashtable first.

    I'm trying to send back a struct with the following types (int, string, string, DateTime, string).

    Is DateTime unable to be serialized? How would I go about converting my struct safely to a byte array to transport it from the server back to the client. I've been searching around but nothing seems to work. Maybe an example of packing it into a hashtable would be helpful. Any help would be greatly appreciated.
  • Boris
    Boris ✭✭
    The struct is a custom type.
    Either put each property of your struct in a hashtable or use one operation response parameter per property.
    Again: Do NOT try to send a custom struct.