/** * 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; }
/* * (non-Javadoc) * * @see * com.aboveware.abovec2dm.server.abovejsonrpc.Storage#delete(java.lang.String * ) */ @Override public void delete() { try { for (String player : getPlayers()) { AccountServer accountServer = AccountServer.fetch(getGamePersistenceManagerServer(), player); accountServer.removeSession(new Sid(getKey())); accountServer.commit(); getPlayer(player).delete(); } getGameServer().delete(); super.delete(); } catch (JSONException e) { // TODO Auto-generated catch block e.printStackTrace(); } }