@Override protected void onCreate(Bundle savedInstanceState) { Log.e(TAG, "onCreate"); super.onCreate(savedInstanceState); MyAppApplication myApp = ((MyAppApplication) getApplicationContext()); mGoogleApiClient = myApp.getClient(); room = myApp.getRoom(); mRoomId = room.getRoomId(); mParticipants = room.getParticipants(); Intent i = getIntent(); myself = (Player) i.getSerializableExtra("myself"); AndroidApplicationConfiguration config = new AndroidApplicationConfiguration(); initialize(new CatMath(this, myself), config); // updated by siyuan myId = room.getParticipantId(Games.Players.getCurrentPlayerId(myApp.getClient())); GameWorld.isOwner = isServer(); Log.e("isOwner:", String.valueOf(GameWorld.isOwner)); playerMap.put(myId, 1); GameWorld.numberOfPlayers = mParticipants.size(); Log.e(TAG, "onCreate ends"); } // end of onCreate
@Override public void onConnectedToRoom(Room room) { if (mRoomId == null) { mRoomId = room.getRoomId(); } // print out the list of participants (for debug purposes) Log.d(TAG, "Room ID: " + mRoomId); Log.d(TAG, "My ID " + myId); Log.d(TAG, "<< CONNECTED TO ROOM>>"); }
@Override public void onRoomCreated(int statusCode, Room room) { if (statusCode != GamesStatusCodes.STATUS_OK) { showGameError(); return; } mRoomId = room.getRoomId(); // show the waiting room UI Intent i = Games.RealTimeMultiplayer.getWaitingRoomIntent(mGoogleApiClient, room, Integer.MAX_VALUE); startActivityForResult(i, RC_WAITING_ROOM); }
public void sendToServer(String message) { byte[] mMsgBuf = message.getBytes(); Games.RealTimeMultiplayer.sendUnreliableMessage( mGoogleApiClient, mMsgBuf, mRoomId, room.getCreatorId()); }