简体   繁体   中英

How to ensure RPC was sent successfully in Photon Unity?

I am building a multiplayer game using Photon and Unity3D engine. I am using photonView.RPC to send data and values between clients. But sometimes due to network problem, a sent RPC failed to execute in the clients.

Is there any way that I can check from the client (who sent the RPC) that the RPC was sent successfully, if not, then again sent the RPC?

Conceptually, the one and only way you can do that is,

A sends the message, with a identity code (say, "321321777")

A waits for confirmation...

B receives the messsage

B sends a message "I received 321321777"

That's really all you can do. Note that this introduces the concept of a time-out . The above actually goes more like this...

A sends the message, with a identity code (say, "321321777")

A waits for confirmation...

If no confirmation after (say) 0.5 seconds, send it again. Keep doing that.

B receives the messsage. The label is 321321777

B sends a message "I received 321321777"

Any more copies of "321321777" received by B, B ignores it . But: if multiple "321321777" received by B, B does again send more and more confirmation messages for "321321777"

It's worth noting that as a general rule, "video games don't work like this." Normally you just send zillions of positions (or whatever) a second, and if a few are missed - it doesn't matter.

Don't forget too that Unity network DOES "reliable sending" for you anyways - and there's probably such a concept in "PUN".

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM