Photon v3 - array of objects

edited October 2011 in Photon Server
Hi.
Dos the v3 version supports sending array of objects of my own class as operation response parameters? Its not working for me, so i am wondering if I am doing something wrong, or its not supported.

My code:

    public class GetBoardResponse
    {
        [DataMember(Code = (byte)CatanParameterKey.cellsArray, IsOptional = false)]
        //public Cell[,] cellArray { get; set; }
        public bool test { get; set; }

        [DataMember(Code = (byte)CatanParameterKey.edgeArray, IsOptional = false)]
        public Edge[] edgeArray { get; set; }
    }
void handleGetBoardOperation(LitePeer peer, GetBoardRequest getBoardRequest, SendParameters sendParameters)
       {
           var getBoardResponse = new GetBoardResponse { test = true, edgeArray = new Edge[10] };
           peer.SendOperationResponse(new OperationResponse(getBoardRequest.OperationRequest.OperationCode, getBoardResponse), sendParameters);
       }

Comments

  • it supports object arrays, yes - meaning that an object[] can contain objects of different types like string, int etc - this includes just the supported types. For custom types like "Edge" you need to register a custom serializer with method Protocol.TryRegisterCustomType.
  • Thank for the answer. Support is really great on this forums :)
    For anyone interested - I used BinaryFormatter to serialise my data on the server and de-serialise it on the client.
    Example how to use it is here:
    http://snippets.dzone.com/posts/show/3897

    It is even working with multi-dimensional arrays (and probably other data structures) of objects of your custom classes.
Sign In or Register to comment.