Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
155 views
in Technique[技术] by (71.8m points)

google play games - Android Real Time Multiplayer - Room Creation is failing

I am using Android Play Games - Real Time Multiplayer for my app. When I create a new room, the callback onRoomCreated() returns STATUS_NETWORK_ERROR_NO_DATA 5% of the times. I do not know why I get this error sporadic.

Some post recommends should be closed before creating a new one. I always leave my rooms before super.onstop() is called. I also wait for the callback onLeftRoom() before creating a new room.

StackTrace

02-20 22:57:07.208: I/libjingle(1763): Token type:OAuth2
02-20 22:57:07.208: I/libjingle(1763): Final XMPP server hostname talk.google.com port to 5222
02-20 22:57:07.316: I/libjingle(1763): OpenSSLAdapter::OnConnectEvent
02-20 22:57:07.416: I/libjingle(1763): BeginSSL: talk.google.com
02-20 22:57:07.476: W/libjingle(1763): Warning(openssladapter.cc:388): ContinueSSL -- error -1
02-20 22:57:07.480: W/libjingle(1763): Warning(openssladapter.cc:397): OpenSSLAdapter::Error(ContinueSSL, -1)
02-20 22:57:07.504: I/libjingle(1763): SSL Cleanup
02-20 22:57:07.532: I/libjingle(1763): Token type:OAuth2
02-20 22:57:07.532: I/libjingle(1763): Final XMPP server hostname talk.google.com port to 5222
02-20 22:57:07.596: I/libjingle(1763): OpenSSLAdapter::OnConnectEvent
02-20 22:57:07.692: I/libjingle(1763): BeginSSL: talk.google.com
02-20 22:57:07.752: W/libjingle(1763): Warning(openssladapter.cc:388): ContinueSSL -- error -1
02-20 22:57:07.752: W/libjingle(1763): Warning(openssladapter.cc:397): OpenSSLAdapter::Error(ContinueSSL, -1)
02-20 22:57:07.764: D/MMC(5796): error onRoomCreated status: STATUS_NETWORK_ERROR_NO_DATA
02-20 22:57:07.796: I/libjingle(1763): SSL Cleanup
02-20 22:57:07.812: D/ChimeraCfgMgr(721): Loading module com.google.android.gms.games from APK com.google.android.play.games
02-20 22:57:07.812: D/ChimeraModuleLdr(721): Module APK com.google.android.play.games already loaded
02-20 22:57:08.520: D/dalvikvm(5796): GC_CONCURRENT freed 1059K, 23% free 8651K/11143K, paused 16ms+1ms, total 42ms
02-20 22:57:12.948: D/dalvikvm(485): GC_CONCURRENT freed 384K, 23% free 5746K/7367K, paused 7ms+1ms, total 18ms
02-20 22:57:24.932: I/Ads(5796): Ad is not visible. Not refreshing ad.
02-20 22:57:24.932: I/Ads(5796): Scheduling ad refresh 60000 milliseconds from now.
02-20 22:57:53.660: D/dalvikvm(5796): GC_CONCURRENT freed 1257K, 25% free 8434K/11143K, paused 22ms+1ms, total 38ms
02-20 22:57:57.044: I/ClearcutLoggerApiImpl(532): disconnect managed GoogleApiClient
02-20 22:57:58.960: I/GLSUser(5709): GLS error: BadAuthentication 123456789 oauth2:https://www.googleapis.com/auth/games
02-20 22:57:58.960: V/GoogleLoginService(5709): Returning error intent with: ComponentInfo{com.google.android.gsf.login/com.google.android.gsf.login.LoginActivity}
02-20 22:57:59.008: W/PlayEventLogger(721): deferring log upload because couldn't retrieve auth token

Does anyone know why I get this error? I am thankful for each hint.

Edit:

I am starting a new game activity from a main menu activity. When the game is over, I am closing the room and then i return to the main menu activity.

Here is an excerpt of the game activity:

private GoogleApiClient mGoogleApiClient;
private String mRoomId;
private final static int RC_WAITING_ROOM = 10002;

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_multiplayer);
    // Create the Google Api Client with access to Plus and Games
    mGoogleApiClient = new GoogleApiClient.Builder(this)
        .addConnectionCallbacks(this)
        .addOnConnectionFailedListener(this)
        .addApi(Plus.API).addScope(Plus.SCOPE_PLUS_LOGIN)
        .addApi(Games.API).addScope(Games.SCOPE_GAMES)
        .build();
}

private void startQuickGame() {
    Log.d("MMC", "debug startgame()");
    // auto-match criteria to invite one random automatch opponent.
    // You can also specify more opponents (up to 3).
    Bundle am = RoomConfig.createAutoMatchCriteria(2, 6, 0);

    // build the room config:
    RoomConfig.Builder roomConfigBuilder = makeBasicRoomConfigBuilder();
    roomConfigBuilder.setAutoMatchCriteria(am);
    RoomConfig roomConfig = roomConfigBuilder.build();

    // create room:
    Games.RealTimeMultiplayer.create(mGoogleApiClient, roomConfig);

    // prevent screen from sleeping during handshake
    getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);

    // go to game screen
}

// create a RoomConfigBuilder that's appropriate for your implementation
private RoomConfig.Builder makeBasicRoomConfigBuilder() {
    Log.d("MMC", "debug makeBasicRoomConfigBuilder()");
    return RoomConfig.builder(this)
        .setMessageReceivedListener(this)
        .setRoomStatusUpdateListener(this);
}


@Override
public void onRoomCreated(int statusCode, Room room) {
    Log.d("MMC", "debug onRoomCreated status:" + statusCode);
    if (statusCode != GamesStatusCodes.STATUS_OK) {
        // let screen go to sleep
        getWindow().clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
        return;
        // show error message, return to main screen.
    }
    mRoomId = room.getRoomId();
    // get waiting room intent
    Intent i = Games.RealTimeMultiplayer.getWaitingRoomIntent(mGoogleApiClient, room, Integer.MAX_VALUE);
    startActivityForResult(i, RC_WAITING_ROOM);
}

@Override
public void onRoomConnected(int statusCode, Room room) {
    Log.d("MMC", "debug onRoomConnected status:" + statusCode);
    if (statusCode != GamesStatusCodes.STATUS_OK) {
        Log.d("MMC", "debug onRoomConnected error");
        // let screen go to sleep
        getWindow().clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
        // show error message, return to main screen.
    }
}

boolean mPlaying = false;

// at least 2 players required for our game
final static int MIN_PLAYERS = 2;

@Override
public void onActivityResult(int request, int response, Intent intent) {
    Log.d("MMC", "debug onActivityResult()");
    if (request == RC_WAITING_ROOM) {
        if (response == Activity.RESULT_OK) {
            // (start game)         
        }
        else if (response == Activity.RESULT_CANCELED) {
            // in this example, we take the simple approach and just leave the room:
            Games.RealTimeMultiplayer.leave(mGoogleApiClient, this, mRoomId);
            getWindow().clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
        }
        else if (response == GamesActivityResultCodes.RESULT_LEFT_ROOM) {
            // player wants to leave the room.
            Games.RealTimeMultiplayer.leave(mGoogleApiClient, this, mRoomId);
            getWindow().clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
        }
    }
}

@Override
public void onDisconnectedFromRoom(Room room) {
    Log.d("MMC", "debug onDisconnectedFromRoom()");
    // leave the room
    Games.RealTimeMultiplayer.leave(mGoogleApiClient, this, mRoomId);

    // clear the flag that keeps the screen on
    getWindow().clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);

    // show error message and return to main screen
}

@Override
public void onLeftRoom(int arg0, String arg1) {
    Log.d("MMC", "debug onLeftRoom() code:" + arg0);
    if(arg1!=null)
        Log.d("MMC", "debug roomId:" + arg1);
    if(!isFinishing())
        finish();       
}

@Override
public void onConnectedToRoom(Room arg0) {
    Log.d("MMC", "debug onConnectedToRoom()");
    Toast.makeText(this, "debug onConnectedToRoom", Toast.LENGTH_SHORT).show();         

}

@Override
public void onConnected(Bundle arg0) {
    // TODO Auto-generated method stub
    Log.d("MMC", "debug onConnected()");
    startQuickGame();
}

@Override
public void onStart() {
    Log.d("MMC", "debug onStart()");
    mGoogleApiClient.connect();
    super.onStart();
}

@Override
public void onStop() {
    Log.d("MMC", "debug onStop()");
    // if we're in a room, leave it.
    leave();
    mGoogleApiClient.disconnect();
    super.onStop();
  }

private void leave(){
    Log.d("MMC", "debug leave()");
    Games.RealTimeMultiplayer.leave(mGoogleApiClient, this, mRoomId);
    getWindow().clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
}

Edit 2:

I receive the same error with googles sample application ButtonClicker2000. Here is the stacktrace: [onRoomCreated(4, null) == NETWORK ERROR]

02-27 10:55:44.343: W/libjingle(1626): Warning(callregistry.cpp:27): void games_rtmp::CallRegistry::UnregisterCall(const string&, const string&): Attempting to erase non-existent session:1153730894
02-27 10:55:44.343: I/libjingle(1626): worker_thread:0xb7bdd4e0 initialized=1
02-27 10:55:44.355: I/libjingle(1626): Channel disabled
02-27 10:55:44.355: I/libjingle(1626): Changing data state, recv=0 send=0
02-27 10:55:44.363: I/libjingle(1626): Destroyed channel
02-27 10:55:44.383: V/GLSActivity(537): AuthDelegateWrapperCreated with selected intent: Intent { cmp=com.google.android.gms/.auth.DefaultAuthDelegateService }
02-27 10:55:44.391: V/GLSActivity(537): AuthDelegateWrapperCreated with selected intent: Intent { cmp=com.google.android.gms/.auth.DefaultAuthDelegateService }
02-27 10:55:44.719: I/libjingle(1626): Parsing Jingle data content
02-27 10:55:44.719: I/libjingle(1626): void gtalk::LibjingleClient::OnCallCreate(cricket::Call*): Connecting to OnAddSession
02-27 10:55:44.719: I/libjingle(1626): Calling Call::IncomingSession()
02-27 10:55:44.719: I/libjingle(1626): AddSession() called. has_data = 1
02-27 10:55:44.719: I/libjingle(1626): Creating data channel.
02-27 10:55:44.719: I/libjingle(1626): Is worker current:0
02-27 10:55:44.719: I/libjingle(1626): Current thread:0xb7c3f920
02-27 10:55:44.719: I/libjingle(1626): worker_thread:0xb7bdd4e0 initialized=1
02-27 10:55:44.719: I/libjingle(1626): Created channel for data
02-27 10:55:44.719: I/libjingle(1626): DataChannel::Init() called
02-27 10:55:44.719: I/libjingle(1626): Setting remote data description
02-27 10:55:44.719: I/libjingle(1626): Added data recv stream '' with ssrc=3755036348
02-27 10:55:44.719: I/libjingle(1626): Add remote ssrc: 3755036348
02-27 10:55:44.719: I/libjingle(1626): DataMediaChannel::SetSendBandwidth to 10485000bps.
02-27 10:55:44.719: I/libjingle(1626): Changing data state, recv=0 send=0
02-27 10:55:44.719: I/libjingle(1626): result = 1
02-27 10:55:44.719: I/libjingle(1626): void gtalk::LibjingleClient::OnAddSession(cricket::Call*, cricket::Session*): OnAddSession called.
02-27 10:55:44.723: I/libjingle(1626): Setting local data description
02-27 10:55:44.723: I/libjingle(1626): Added data send stream '' with ssrc=2649333871
02-27 10:55:44.723: I/libjingle(1626): Add send ssrc: 2649333871
02-27 10:55:44.723: I/libjingle(1626): SRTP reset to init state
02-27 10:55:44.723: I/libjingle(1626): Changing data state, recv=0 send=0
02-27 10:55:44.731: E/libjingle(1626): Error(latencyprober.cpp:83): Peer already added for reliable latency metrics.
02-27 10:55:44.731: I/libjingle(1626): Channel enabled
02-27 10:55:44.731: I/libjingle(1626): Changing data state, recv=1 send=0
02-27 10:55:44.735: I/libjingle(1626): Network Information: All networks
02-27 10:55:44.735: I/libjingle(1626): Name, Description, Prefix, Prefix Length, IP, ignored
02-27 10:55:44.735: I/libjingle(1626): ipv4-default default IPV4 network 0.0.0.0 32 10.0.3.15 0
02-27 10:55:44.735: I/libjingle(1626): eth0 eth0 192.168.169.0 24 192.168.169.101 0
02-27 10:55:44.735: I/libjingle(1626): eth1 eth1 10.0.3.0 24 10.0.3.15 0
02-27 10:55:44.735: I/libjingle(1626): eth0 eth0 fe

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

A checklist for you..I hope it will help you

1.check have you added Test accounts

2.check whether you turn on Realtime Multiplayer in google play developer console for your game.

3.Check required meta tags in androidMainfest file


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...