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());
}