@Override protected void onDestroy() { Log.d(TAG, "onDestroy"); super.onDestroy(); Games.RealTimeMultiplayer.leave(mGoogleApiClient, this, mRoomId); Gdx.app.exit(); GameWorld.reset(); // gameHelper.onStop(); }
@Override public void onJoinedRoom(int statusCode, Room room) { if (statusCode != GamesStatusCodes.STATUS_OK) { showGameError(); return; } // show the waiting room UI Intent i = Games.RealTimeMultiplayer.getWaitingRoomIntent(mGoogleApiClient, room, Integer.MAX_VALUE); startActivityForResult(i, RC_WAITING_ROOM); }
public void sendToPlayerReliable(String message) { Log.d(TAG, "SENDRELIABLE" + message); byte[] mMsgBuf = message.getBytes(); if (mParticipants != null) { for (Participant p : mParticipants) { if (!p.getParticipantId().equals(myId)) { Games.RealTimeMultiplayer.sendReliableMessage( mGoogleApiClient, null, mMsgBuf, mRoomId, p.getParticipantId()); } } } }
@Override public void startQuickGame() { Log.e(TAG, "startQuickGame"); final int MIN_OPPONENTS = 1, MAX_OPPONENTS = 2; Bundle autoMatchCriteria = RoomConfig.createAutoMatchCriteria(MIN_OPPONENTS, MAX_OPPONENTS, 0); RoomConfig.Builder roomConfigBuilder = RoomConfig.builder(this); roomConfigBuilder.setMessageReceivedListener(this); roomConfigBuilder.setAutoMatchCriteria(autoMatchCriteria); RoomConfig roomConfig = roomConfigBuilder.build(); // create room: Games.RealTimeMultiplayer.create(myApp.getClient(), roomConfig); // NEXT: onRoomCreated }
@Override public void sendToOnePlayer(String id, String message) { byte[] mMsgBuf = message.getBytes(); Games.RealTimeMultiplayer.sendUnreliableMessage(mGoogleApiClient, mMsgBuf, mRoomId, id); }
public void sendToServer(String message) { byte[] mMsgBuf = message.getBytes(); Games.RealTimeMultiplayer.sendUnreliableMessage( mGoogleApiClient, mMsgBuf, mRoomId, room.getCreatorId()); }