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
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
0
Comments
-
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" useloadBalancingClient.OpRaiseEvent
- To receive useloadBalancingClient.OnEventAction
(or overrideloadBalancingClient.OnEvent
)
To achieve the 60 times per second, you can useloadBalancingClient.Service
and call it 60 times per second or if you want more fine grain and better way of doing things, you can callloadBalancingPeer.SendOutgoingCommands
after eachloadBalancingClient.OpRaiseEvent
and n times per second to make sure other commands are also sent. To process the incoming commands callloadBalancingPeer.DispatchIncomingCommands
also m times per second.1