[英]How to ensure RPC was sent successfully in Photon Unity?
I am building a multiplayer game using Photon and Unity3D engine. 我正在使用Photon和Unity3D引擎构建多人游戏。 I am using photonView.RPC to send data and values between clients.
我正在使用photonView.RPC在客户端之间发送数据和值。 But sometimes due to network problem, a sent RPC failed to execute in the clients.
但是有时由于网络问题,发送的RPC无法在客户端中执行。
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? 我有什么方法可以从客户端(发送RPC的客户端)检查RPC是否已成功发送,如果没有成功,则再次发送RPC?
Conceptually, the one and only way you can do that is, 从概念上讲,您可以做到的唯一方法是,
A sends the message, with a identity code (say, "321321777")
A发送带有身份代码的消息(例如“ 321321777”)
A waits for confirmation...
等待确认...
B receives the messsage
B收到消息
B sends a message "I received 321321777"
B发送消息“我收到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发送带有身份代码的消息(例如“ 321321777”)
A waits for confirmation...
等待确认...
If no confirmation after (say) 0.5 seconds, send it again.
如果在0.5秒后仍未确认,请再次发送。 Keep doing that.
继续做。
B receives the messsage.
B收到消息。 The label is 321321777
标签是321321777
B sends a message "I received 321321777"
B发送消息“我收到321321777”
Any more copies of "321321777" received by B, B ignores it .
B收到的“ 321321777”的任何更多副本, B将忽略它 。 But: if multiple "321321777" received by B, B does again send more and more confirmation messages for "321321777"
但是:如果B收到多个“ 321321777”,则B确实会再次发送越来越多的“ 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". 也不要忘记Unity网络确实可以为您“可靠发送”-“ PUN”中可能有这样的概念。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.