简体   繁体   中英

sendReliableMessage to self? Google Play Game Services - Android

I am trying to create a real-time multiplayer game using Google Play Game Services. I am trying to set one player as host. Everyone will send their commands to the host (via sendReliableMessage), and they will receive a response of what to render.

However, I am trying to have the host send himself a message (before acting) in order to be in sync with everyone else, but the onRealTimeMessageReceived is not firing for the host when the host himself sends out the message.

Is it possible for the host to send a message to himself? If not, how would I go about this? The Google tutorial even says I should have a host player.

You cannot do this using the sendReliableMessage() function in RealTimeMultiplayer class. As written here , the function throws an IllegalArgumentException if recipientParticipantId is not a valid participant or belongs to the current player .

The thing that you need to do is to forward all received messages (sent by others) to a common class/method etc (depending on your design/wish) to keep clients updated and keep your game logic running and call the class/method manually for the host.

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