/** * Remove a player from the session * * @param session the session to be removed from * @param key the player to remove * @throws JDOObjectNotFoundException */ public void remove(String account) throws JDOObjectNotFoundException { for (String player : getPlayers()) { if (player.equalsIgnoreCase(account)) { removeListItem(player); commit(); return; } } }
/** * Add a new player to the session * * @param account the account for the new player * @return success if successfully added player, failure otherwise * @throws JSONException * @throws JDOObjectNotFoundException */ public JsonReturn addPlayer(String account) throws JSONException, JDOObjectNotFoundException { JsonReturn returnValue = new JsonReturn(JsonReturn.value.FAIL); AccountServer accountServer = AccountServer.fetch(gamePersistenceManagerServer, account); if (null != accountServer) { returnValue = getGameServer().addPlayer(this, account, getList().size()); if (returnValue.success()) { accountServer.addSession(new Sid(getKey())); accountServer.commit(); addListItem(account); commit(); } } return returnValue; }
@Override public void commit() { commit(SessionServer.class); }