Help With Exception in Protocol - Exception: Read failed. Custom type not found: X

Options
I have registered a custom type and provided the de/serialization methods, etc. In my case I'm using 'S' (ie byte value 83) for my custom type. And upon reading incoming events I get the following:
Exception: Read failed. Custom type not found: 83
ExitGames.Client.Photon.Protocol18.ReadCustomType (ExitGames.Client.Photon.StreamBuffer stream, Byte gpType) (at C:/Dev/photon-sdk-dotnet/PhotonDotnet/Protocol18Read.cs:247)
ExitGames.Client.Photon.Protocol18.Read (ExitGames.Client.Photon.StreamBuffer stream, Byte gpType) (at C:/Dev/photon-sdk-dotnet/PhotonDotnet/Protocol18Read.cs:20)
ExitGames.Client.Photon.Protocol18.Read (ExitGames.Client.Photon.StreamBuffer stream) (at C:/Dev/photon-sdk-dotnet/PhotonDotnet/Protocol18Read.cs:13)
ExitGames.Client.Photon.Protocol18.ReadHashtable (ExitGames.Client.Photon.StreamBuffer stream) (at C:/Dev/photon-sdk-dotnet/PhotonDotnet/Protocol18Read.cs:307)
ExitGames.Client.Photon.Protocol18.Read (ExitGames.Client.Photon.StreamBuffer stream, Byte gpType) (at C:/Dev/photon-sdk-dotnet/PhotonDotnet/Protocol18Read.cs:82)
ExitGames.Client.Photon.Protocol18.Read (ExitGames.Client.Photon.StreamBuffer stream) (at C:/Dev/photon-sdk-dotnet/PhotonDotnet/Protocol18Read.cs:13)
ExitGames.Client.Photon.Protocol18.ReadHashtable (ExitGames.Client.Photon.StreamBuffer stream) (at C:/Dev/photon-sdk-dotnet/PhotonDotnet/Protocol18Read.cs:307)
ExitGames.Client.Photon.Protocol18.Read (ExitGames.Client.Photon.StreamBuffer stream, Byte gpType) (at C:/Dev/photon-sdk-dotnet/PhotonDotnet/Protocol18Read.cs:82)
ExitGames.Client.Photon.Protocol18.ReadParameterTable (ExitGames.Client.Photon.StreamBuffer stream) (at C:/Dev/photon-sdk-dotnet/PhotonDotnet/Protocol18Read.cs:289)
ExitGames.Client.Photon.Protocol18.DeserializeOperationResponse (ExitGames.Client.Photon.StreamBuffer stream) (at C:/Dev/photon-sdk-dotnet/PhotonDotnet/Protocol18Read.cs:339)
ExitGames.Client.Photon.PeerBase.DeserializeMessageAndCallback (ExitGames.Client.Photon.StreamBuffer stream) (at C:/Dev/photon-sdk-dotnet/PhotonDotnet/PeerBase.cs:609)
ExitGames.Client.Photon.EnetPeer.DispatchIncomingCommands () (at C:/Dev/photon-sdk-dotnet/PhotonDotnet/EnetPeer.cs:550)
ExitGames.Client.Photon.PhotonPeer.DispatchIncomingCommands () (at C:/Dev/photon-sdk-dotnet/PhotonDotnet/PhotonPeer.cs:1422)
Photon.Pun.PhotonHandler.FixedUpdate () (at Assets/Photon/PhotonUnityNetworking/Code/PhotonHandler.cs:130)
I have several other custom types, both classes and structs, but they do not have a problem. This particular type is my own container type SyncListInt. There is another mention of this exception in https://forum.photonengine.com/discussion/12634/pun-equivalent-for-unet-synclist . I thought this problem had gone away before, but it recently started happening again.

I could really use some help understanding what this is as it's all in the compiled protocol.

Comments

  • bump.
    Please - can anyone shed some light on this for me? I get this exception every time a remote client attempts to sync the data type I've registered as 83 ((byte)'S').
  • jeanfabre
    Options
    Hi,

    how do you use your data, meaning, what is your protocole for sending and receiving this data inside PUN? are you using a photonView, an RPC, or else?

    Bye,

    Jean
  • I have all of my "custom" player data added to the Photon.Realtime.Player class by way of changing the class to a partial class definition. Properties get modified by my game logic, and every 0.5 seconds I call SetPropertValues.

    Here is how I send the changed values:
    private void SetPropertyValue(string propertyName, object value)
    {
    if (!this.IsLocal || this.RoomReference == null || !this._setEnabled) return;

    lock (lockObj)
    {
    _changedExtendedProperties[propertyName] = value;
    }
    }
    private void SetPropertyValues()
    {
    lock (lockObj)
    {
    if (_changedExtendedProperties.Count == 0) return;

    if (this.RoomReference.IsOffline)
    {
    // invoking callbacks
    this.RoomReference.LoadBalancingClient.InRoomCallbackTargets.OnPlayerPropertiesUpdate(this, _changedExtendedProperties);
    }
    else
    {
    // send (sync) these new values if in online room
    this.RoomReference.LoadBalancingClient.LoadBalancingPeer.OpSetPropertiesOfActor(this.actorNumber, _changedExtendedProperties);
    }

    _changedExtendedProperties.Clear();
    }
    }
    Here is an example of how I use it for an int:
    public delegate void AvatarIndexValueChangedHandler(int value);
    public event AvatarIndexValueChangedHandler OnAvatarIndexValueChanged;

    public const string AVATAR_INDEX_PROP_NAME = "P0";
    private int avatarIndex = 0;

    public int AvatarIndex
    {
    get
    {
    return this.avatarIndex;
    }
    set
    {
    if (this.avatarIndex == value) return;
    this.avatarIndex = value;
    this.SetPropertyValue(AVATAR_INDEX_PROP_NAME, value);
    if (OnAvatarIndexValueChanged != null) OnAvatarIndexValueChanged(this.avatarIndex);
    }
    }
  • jeanfabre
    Options
    Hi,

    ok, you should switch to using a photonView, observing a monobehaviour, and sync your data using OnPhotonSerializeView() callback.

    https://doc.photonengine.com/en-us/pun/v2/getting-started/pun-intro

    check under GameLogic section on how to implement OnPhotonSerializeView


    Bye,

    Jean

  • To receive changes from remote, I have a MonoBehaviourPunCallbacks object which results in the following method being called:
    private void HandlePlayerPropertiesUpdated(Photon.Realtime.Player targetPlayer, Hashtable changedProps)
    {
    // prevent infinite set looping
    targetPlayer._setEnabled = false;

    if (changedProps.ContainsKey(AVATAR_INDEX_PROP_NAME)) targetPlayer.AvatarIndex = Convert.ToInt32(changedProps[AVATAR_INDEX_PROP_NAME]);
    //...

    targetPlayer._setEnabled = true;
    }