Possible to PhotonPeer.RegisterType more than once?

Options
mcodes
edited August 2012 in Photon Server
Hi,

I have an operation (byte=1) that sends multiple custom type objects in the response. I want my client to be able to serialize them from the network so I tried to PhotonPeer.RegisterType for each object using the same byte code but it throws an exception for the second registration:
// Register SharedUserProfile for serialization.
            if (!PhotonPeer.RegisterType(typeof(SharedUserProfile), (byte)OperationCodes.Connect, SharedUserProfile.Serialize, SharedUserProfile.Deserialize))
            {
                throw new Exception("Failed to register SharedUserProfile for serialize/deserialize.");
            }
            
            // Register OnlineGameState for serialization. The following line returns false!!!
            if (!PhotonPeer.RegisterType(typeof(OnlineGameState), (byte)OperationCodes.Connect, OnlineGameState.Serialize, OnlineGameState.Deserialize))
            {
                throw new Exception("Failed to register OnlineGameState for serialize/deserialize.");
            }

Is it possible to register more than one type or will I have to wrap these in a wrapper class and register a single type?

Thanks

Comments

  • [Deleted User]
    Options
    Hi mcodes,

    it is surely possible to register more then one type. But you need to register each type on its own byte code in order to get things working. Otherwise, registering will fail because of the double use of byte codes. These codes are used to identify the registered type while it is sent.

    Hope that helps.


    Tim
  • Is the byte supposed to correspond with the Operation byte code, or is it arbitrary?
  • Kaiserludi
    Options
    It is arbitrary.