Google Play ゲーム サービスを使用して、メッセージの送信に問題がある場合は、それを解決する必要があるように CallBack を実装しようとしています (各プレーヤーが入札を次のプレーヤーに「渡し」、他のすべてのプレーヤーに入札を「渡す」ため)。プレーヤーは、入札に合格したプレーヤーを確認する必要があります)
メッセージが全員に送受信されたかどうかを確認できるように、以下を使用して、そのラウンドのメッセージの RealTimeReliableMessageSentListener をインスタンス化しようと考えました。
(呼び出しによって返された tokenID を ArrayList に追加し、このラウンドからのすべてのメッセージがいつ受信されたかを追跡するために、各 tokenID が戻ってきたら削除することをオフにします)
@Override
public void sendReadyToPlay() {
dLog("Sending ReadyToPlay");
// Broadcast that I'm ready, and see that they are ready
if (!mMultiplayer){
return; // playing against computer
}
// First byte in message indicates whether it's a final score or not
mMsgBuf[0] = (byte) ('R');
readyToPlayTokens.clear();
// Send to every other participant.
for (Participant p : mParticipants) {
dLog("Participant:" + p.getParticipantId());
if (p.getParticipantId().equals(mMyId)) {
continue;}
if (p.getStatus() != Participant.STATUS_JOINED){
continue;
}
readyToPlayTokens.add(mHelper.getGamesClient().sendReliableRealTimeMessage(new RealTimeReliableMessageSentListener() {
@Override
public void onRealTimeMessageSent(int statusCode, int tokenId, String recipientParticipantId){
dLog("onRealTimeMessageSent number two and size is: " + readyToPlayTokens.size());
if(readyToPlayTokens.contains(tokenId)){
readyToPlayTokens.remove(tokenId);
}
dLog("onRealTimeMessageSent number two and size is: " + readyToPlayTokens.size());
if (statusCode != GamesClient.STATUS_OK) {
mGHInterface.onRealTimeMessageReceived("RTPProblem:" + recipientParticipantId);
} else if (readyToPlayTokens.size() == 0) {
mGHInterface.beginRound();
}
}
}, mMsgBuf, mRoomId, p.getParticipantId()));
dLog("sent to:" + p.getParticipantId());
}
}
ほぼ毎回、あるデバイスから別のデバイスにメッセージが着信していることがわかるので、メッセージが通過していることがわかりますが、RealTimeReliableMessageSent リスナーは約 50 ~ 60% の時間しか起動されていません。信頼性のある!:)
リスナーが確実に発火しないようにするために私が間違っていることを誰かが見ることができますか?