Package com.threerings.presents.server

Examples of com.threerings.presents.server.InvocationException


    public Table createTable (BodyObject creator, TableConfig tableConfig, GameConfig config)
        throws InvocationException
    {
        // make sure the caller is not already in a table
        if (_boidMap.containsKey(creator.getOid())) {
            throw new InvocationException(ALREADY_AT_TABLE);
        }

        // create a brand spanking new table
        Table table;
        try {
            table = _tableClass.newInstance();
        } catch (Exception e) {
            log.warning("Table.newInstance() failed", "class", _tableClass, e);
            throw new InvocationException(INTERNAL_ERROR);
        }
        table.init(_dobj.getOid(), tableConfig, config);

        if (table.bodyOids != null && table.bodyOids.length > 0) {
            // stick the creator into the first non-AI position
            int cpos = (config.ais == null) ? 0 : config.ais.length;
            String error = table.setPlayer(cpos, creator);
            if (error != null) {
                log.warning("Unable to add creator to position zero of table!?",
                   "table", table, "creator", creator, "error", error);
                // bail out now and abort the table creation process
                throw new InvocationException(error);
            }

            // make a mapping from the creator to this table
            notePlayerAdded(table, creator);
        }
View Full Code Here


        // in which they are requesting to create a table
        if (_dobj instanceof PlaceObject &&
            !((PlaceObject)_dobj).occupants.contains(creator.getOid())) {
            log.warning("Requested to create a table in a place not occupied by the creator",
                "creator", creator, "ploid", _dobj.getOid());
            throw new InvocationException(INTERNAL_ERROR);
        }

        // if createTable() returns, we're good to go
        listener.requestProcessed(createTable(creator, tableConfig, config).tableId);
    }
View Full Code Here

    {
        BodyObject joiner = (BodyObject)caller;

        // make sure the caller is not already in a table
        if (_boidMap.containsKey(joiner.getOid())) {
            throw new InvocationException(ALREADY_AT_TABLE);
        }

        // look the table up
        Table table = _tables.get(tableId);
        if (table == null) {
            throw new InvocationException(NO_SUCH_TABLE);
        }

        // request that the user be added to the table at that position
        String error = table.setPlayer(position, joiner);
        // if that failed, report the error
        if (error != null) {
            throw new InvocationException(error);
        }

        // if the table is sufficiently full, start the game automatically
        if (table.shouldBeStarted()) {
            createGame(table);
View Full Code Here

        BodyObject leaver = (BodyObject)caller;

        // look the table up
        Table table = _tables.get(tableId);
        if (table == null) {
            throw new InvocationException(NO_SUCH_TABLE);
        }

        // if the table is in play, the user is not allowed to leave (he must leave the game)
        if (table.inPlay()) {
            throw new InvocationException(GAME_ALREADY_STARTED);
        }

        // request that the user be removed from the table
        if (!table.clearPlayer(leaver.getVisibleName())) {
            throw new InvocationException(NOT_AT_TABLE);
        }

        // remove the mapping from this user to the table
        if (null == notePlayerRemoved(leaver.getOid(), leaver)) {
            log.warning("No body to table mapping to clear?",
View Full Code Here

        throws InvocationException
    {
        BodyObject starter = (BodyObject)caller;
        Table table = _tables.get(tableId);
        if (table == null) {
            throw new InvocationException(NO_SUCH_TABLE);
        } else if (starter.getOid() != table.bodyOids[0]) {
            throw new InvocationException(MUST_BE_CREATOR);
        } else if (!table.mayBeStarted()) {
            throw new InvocationException(INTERNAL_ERROR);
        }
        createGame(table);
    }
View Full Code Here

    {
        BodyObject booter = (BodyObject) caller;
        Table table = _tables.get(tableId);

        if (table == null) {
            throw new InvocationException(NO_SUCH_TABLE);
        } else if ( ! _allowBooting) {
            throw new InvocationException(INTERNAL_ERROR);
        }

        int position = ListUtil.indexOf(table.players, target);
        if (position < 0) {
            throw new InvocationException(NOT_AT_TABLE);
        } else if (booter.getOid() != table.bodyOids[0]) {
            throw new InvocationException(MUST_BE_CREATOR);
        } else if (booter.getOid() == table.bodyOids[position]) {
            throw new InvocationException(NO_SELF_BOOT);
        }

        // Remember to keep him banned
        table.addBannedUser(target);
View Full Code Here

            gameCreated(table, gobj, gmgr);
            return gobj.getOid();

        } catch (Throwable t) {
            log.warning("Failed to create manager for game", "config", table.config, t);
            throw new InvocationException(INTERNAL_ERROR);
        }
    }
View Full Code Here

     */
    protected void verifyIsPlayer (ClientObject caller)
        throws InvocationException
    {
        if (!isPlayer(caller)) {
            throw new InvocationException(InvocationCodes.E_ACCESS_DENIED);
        }
    }
View Full Code Here

     */
    protected void verifyIsPlayerOrAgent (ClientObject caller)
        throws InvocationException
    {
        if (!isPlayer(caller) && !isAgent(caller)) {
            throw new InvocationException(InvocationCodes.E_ACCESS_DENIED);
        }
    }
View Full Code Here

    {
        verifyIsPlayerOrAgent(caller);

        BodyObject player = _gmgr.checkWritePermission(caller, playerId);
        if (player == null) {
            throw new InvocationException(InvocationCodes.ACCESS_DENIED);
        }
        return player;
    }
View Full Code Here

TOP

Related Classes of com.threerings.presents.server.InvocationException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.