Google Play Services RealTimeMultiplayer OnP2PDisconnected() callback not working on Android devices

All callbacks for IRealTimeEventListener are not working on Android devices except for OnDataReceived(). They all work perfectly on iPhone emulator.

Android build command:

cocos run -p android -m release

Callbacks not working:

    //IRealTimeEventListener
    void OnRoomStatusChanged(gpg::RealTimeRoom const &room) override;
    void OnConnectedSetChanged(gpg::RealTimeRoom const &room) override;
    void OnP2PConnected(gpg::RealTimeRoom const &room, gpg::MultiplayerParticipant const &participant) override;
    void OnP2PDisconnected(gpg::RealTimeRoom const &room, gpg::MultiplayerParticipant const &participant) override;
    void OnParticipantStatusChanged(gpg::RealTimeRoom const &room, gpg::MultiplayerParticipant const &participant) override;

All other aspects of the GPS implementation work on both Android device and iPhone emulator, i.e. Creating rooms, connecting players, sending data, etc.

EDIT: Only OnP2PDisconnected() not working.

Nobody else having this problem?

Dose the gpg sample works for you?

Bump still having this issue. The problem is only on Android devices.

I’m following this example given by sdkbox IRealTimeMultiplayer game room callbacks.

Github repo https://github.com/damorton/TestGPG

The samples have the same issues. A specific example is the OnP2PDisconnected callback. This works if I close the app on the android device while connected to an iPhone emulator, the callback is hit on the iPhone emulator. But If I disconnect on the iPhone emulator the android device is not notified.

Similarly if I have two Android devices connected, if the app is closed on either the opposite device is not notified of the disconnection through the callback.

Is there a setting I need to have in the manifest that allows these callbacks to work. Its strange because the onDataReceived() callback works fine in all cases.

Following this sdkbox example

HelloWorld.h

  //IRealTimeEventListener
  void OnRoomStatusChanged(gpg::RealTimeRoom const &room) override;
  void OnConnectedSetChanged(gpg::RealTimeRoom const &room) override;
  void OnP2PConnected(gpg::RealTimeRoom const &room, gpg::MultiplayerParticipant const &participant) override;
  void OnP2PDisconnected(gpg::RealTimeRoom const &room, gpg::MultiplayerParticipant const &participant) override;
  void OnParticipantStatusChanged(gpg::RealTimeRoom const &room, gpg::MultiplayerParticipant const &participant) override;
  void OnDataReceived(gpg::RealTimeRoom const &room, gpg::MultiplayerParticipant const &from_participant, std::vector<uint8_t> data, bool is_reliable)
  override;

HelloWorld.cpp

//
// IRealtimeEventListener
//
void HelloWorld::OnRoomStatusChanged(gpg::RealTimeRoom const &room) {
  CCLOG("Room Status Change %d", room.Status());
}

void HelloWorld::OnConnectedSetChanged(gpg::RealTimeRoom const &room) {
  CCLOG("Connection Change %d", room.Status());
}

void HelloWorld::OnP2PConnected(gpg::RealTimeRoom const &room, gpg::MultiplayerParticipant const &participant) {
  CCLOG("P2P Connected %s : %s", room.Id().c_str(), participant.DisplayName().c_str());
}

void HelloWorld::OnP2PDisconnected(gpg::RealTimeRoom const &room, gpg::MultiplayerParticipant const &participant) {
  CCLOG("P2P Disconnected %s : %s", room.Id().c_str(), participant.DisplayName().c_str());
  cocos2d::Director::getInstance()->end();
}

void HelloWorld::OnParticipantStatusChanged(gpg::RealTimeRoom const &room, gpg::MultiplayerParticipant const &participant) {
  CCLOG("Participant Status Change %s : %s", room.Id().c_str(), participant.DisplayName().c_str());
}

void HelloWorld::OnDataReceived(gpg::RealTimeRoom const &room, gpg::MultiplayerParticipant const &from_participant, std::vector<uint8_t> data, bool is_reliable) {
  CCLOG("Recv data from %s : %s", room.Id().c_str(), from_participant.DisplayName().c_str());
}

Bump. Anyone have any ideas?

After some investigation it turns out that only OnP2PDisconnected callback for RealTimeMultiplayer games does not work on android, the only one I need for now :frowning:

Does anyone know why?

Bump. Is this a problem with SDKBOX on Android?

Are you trying to detect a player exits the game? I think OnParticipantStatusChanged can also be used to detect player exiting

Yes I’m trying to find out if a player leaves the game. These callbacks are not reliable. I’m assuming its because of network issues.

Hi there,

I think I have the same issue. Is it the same as this that I’ve flagged up?

Did you ever find a fix?

Steve.