[Help] PhotonStream's index wraps around from 126 to 0

Hello,

After hours of debugging, I came to the realization that, if I write more than 126 items in a photonStream,the 126th time I do ReceiveNext(), I actually get the FIRST element (element at index 0 of readData array), as opposed to the 126th element.
127th element will get the element at index 1, and 128th element will get the element at index 2.

It appears that every index gets transformed using a modulo 126 operation, before fetching the data,

Is this behaviour expected?
What kind of solutions could I adopt to fix this problem?

Comments

  • Hi @Immerxed_Bar,

    can you paste the code snippet where the error is thrown? I tested this with the OnPhotonSerializeView function by writing 200 elements to the stream using a for-loop. Result is that all the 200 elements were successfully delivered to the receiver. Even using an int array with 200 elements worked fine for me.
  • edited February 1
    Could you do the same test with 300 items? I think I have miscounted the number of elements I put on the stream.
    I was thinking about it again, and you're right. The number I gave you isn't correct.
    I put at least twice as many elements, plus two more elements to mark beginning and end of chunk of data, so at least 254 elements. I'm thinking it probably breaks at index 255, a number that makes me think about a byte used as index...

    Wait a second....
    The variable used as index (currentItem) for access the array is defined as byte.....
    But why?
  • Can I change it without breaking anything else?
  • By default OnPhotonSerializeView is called 20 times per second and is used for frequent updates, for example for the position of a moving object. Sending that amount of data multiple times a second will result in a lot of traffic which you definitely want to avoid. Can you describe the scenario why you want to send that much data using the OnPhotonSerializeView function?

    Can I change it without breaking anything else?


    If you still want to handle this scenario, you can test this yourself and see if it is still working afterwards - I honestly don't know this and I would not recommend this at all.
  • By default OnPhotonSerializeView is called 20 times per second and is used for frequent updates, for example for the position of a moving object. Sending that amount of data multiple times a second will result in a lot of traffic which you definitely want to avoid. Can you describe the scenario why you want to send that much data using the OnPhotonSerializeView function?



    I'm trying to create a Sync Var attribute. I am using a centralized system, so all of the data goes in and out through the same PhotonStream.
    Only variables that have been actually changed are passed through, so the amount of data going into the stream is not constant, but sometimes it can spike.

    Would you suggest a different solution to achieve my goal?
  • Only variables that have been actually changed are passed through, so the amount of data going into the stream is not constant, but sometimes it can spike.


    I'm not sure if you will have the same problem if you have such an spike even when using another approach (for example RaiseEvent).
Sign In or Register to comment.