Code example for PlusClient

Methods: disconnect, isConnected

0
        mConnectionResult = null;
        mAutoSignIn = false;
        mSignedIn = false;
        mSignInError = false;
 
        if (mPlusClient != null && mPlusClient.isConnected()) {
            mPlusClient.clearDefaultAccount();
        } 
        if (mGamesClient != null && mGamesClient.isConnected()) {
//            showProgressDialog(false); 
            mGamesClient.signOut(this);
        } 
 
        // kill connects to all clients but games, which must remain 
        // connected til we get onSignOutComplete() 
        killConnections(CLIENT_ALL & ~CLIENT_GAMES);		
	} 
	 
	public boolean silentSignIn() { 
		return signIn(); 
	} 
	 
	public boolean signIn() { 
		if(hasAuthorised()) 
			return true; // already authorised 
			 
		mConnectedClients = CLIENT_NONE;
//	    mInvitationId = null; 
	    connectNextClient(); 
		return true; 
	} 
	 
	private void connectNextClient() { 
        // do we already have all the clients we need? 
        int pendingClients = mRequestedClients & ~mConnectedClients;
        if (pendingClients == 0) {
            debugLog("All clients now connected. Sign-in successful."); 
            succeedSignIn(); 
            return; 
        } 
 
        // which client should be the next one to connect? 
        if (mGamesClient != null && (0 != (pendingClients & CLIENT_GAMES))) {
            debugLog("Connecting GamesClient."); 
            mClientCurrentlyConnecting = CLIENT_GAMES;
        } else if (mPlusClient != null && (0 != (pendingClients & CLIENT_PLUS))) {
            debugLog("Connecting PlusClient."); 
            mClientCurrentlyConnecting = CLIENT_PLUS;
        } else if (mAppStateClient != null && (0 != (pendingClients & CLIENT_APPSTATE))) {
            debugLog("Connecting AppStateClient."); 
            mClientCurrentlyConnecting = CLIENT_APPSTATE;
        } else { 
            throw new AssertionError("Not all clients connected, yet no one is next. R="
                    + mRequestedClients + ", C=" + mConnectedClients);
        } 
 
        connectCurrentClient(); 
    } 
 
	void connectCurrentClient() { 
        switch (mClientCurrentlyConnecting) {
            case CLIENT_GAMES:
            	mParentActivity.runOnUiThread(new Runnable() {
 
					public void run() { 
						mGamesClient.connect();
					}            		 
            	}); 
                 
                break; 
            case CLIENT_APPSTATE:
            	mParentActivity.runOnUiThread(new Runnable() {
					public void run() { 
						mAppStateClient.connect();
					} 
            	}); 
                 
                break; 
            case CLIENT_PLUS:
            	mParentActivity.runOnUiThread(new Runnable() {
            		public void run() { 
            			mPlusClient.connect();
            		} 
            	}); 
                break; 
        } 
    } 
	 
	void succeedSignIn() { 
        debugLog("All requested clients connected. Sign-in succeeded!"); 
        mSignedIn = true;
        mSignInError = false;
        mAutoSignIn = true;
        mUserInitiatedSignIn = false;
        UnitySendMessageSafe("GPGAuthResult", "success"); 
    } 
 
 
	void killConnections(int whatClients) {
        if ((whatClients & CLIENT_GAMES) != 0 && mGamesClient != null
                && mGamesClient.isConnected()) {
            mConnectedClients &= ~CLIENT_GAMES;
            mGamesClient.disconnect();
        } 
        if ((whatClients & CLIENT_PLUS) != 0 && mPlusClient != null
                && mPlusClient.isConnected()) {
            mConnectedClients &= ~CLIENT_PLUS;
            mPlusClient.disconnect();
        } 
        if ((whatClients & CLIENT_APPSTATE) != 0 && mAppStateClient != null
                && mAppStateClient.isConnected()) {
            mConnectedClients &= ~CLIENT_APPSTATE;
            mAppStateClient.disconnect();