Fast bytes exchange between 2 players

Options
Hello,

I just started to learn PUN. I started with documentation, but I find it extremely confusing.
I would like to ask if it is possible to use PUN for the following scenario:
I would like to join two players in one room. Each player should have ability to send explicitly bytes array to another player. In essence, I just need:
- some method "Send" which can be called in each "Update" method (60 times per second) to send bytes array to remote player
- some method "Receive" (or event "OnReceived") which can be used to receive bytes array from remote player (60 times per second)

Is there a way to achieve this using PUN? In the documentation I found only "Photon View" script which observes objects and somehow send changes. I need more control over messages exchange process.

best regards,
Radik

Comments

  • JohnTube
    JohnTube ✭✭✭✭✭
    edited May 2018
    Options
    Hi @Radik,

    Thank you for choosing Photon!

    You probably don't need PUN but rather Photon Realtime Unity SDK which gives you more ("lower level") control.
    What you need is to exchange custom events with byte array as data and <an> event code<s> of your choice.
    - To "Send" use loadBalancingClient.OpRaiseEvent
    - To receive use loadBalancingClient.OnEventAction (or override loadBalancingClient.OnEvent)

    To achieve the 60 times per second, you can use loadBalancingClient.Service and call it 60 times per second or if you want more fine grain and better way of doing things, you can call loadBalancingPeer.SendOutgoingCommands after each loadBalancingClient.OpRaiseEvent and n times per second to make sure other commands are also sent. To process the incoming commands call loadBalancingPeer.DispatchIncomingCommands also m times per second.