Package org.jaibo.api.dataserver

Examples of org.jaibo.api.dataserver.DataServerInfoObject


    }

    @Override
    protected String action() {
        DataServerInfoPackage infoPackage = new DataServerInfoPackage();
        DataServerInfoObject infoObject = new DataServerInfoObject();

        String[] extensionNames = this.extensionObject.getExtensionManager().getAllExtensionList();
        ArrayList<DataServerInfoObject> extensions = new ArrayList<DataServerInfoObject>();

        for (int i = 0; i < extensionNames.length; i++) {
            DataServerInfoObject extensionObject = new DataServerInfoObject();
            String extensionName = extensionNames[i];
            boolean isRunning = this.extensionObject.getExtensionManager().isExtensionAlreadyAdded(extensionName);

            extensionObject.putData("running", isRunning);
            extensionObject.putData("extension", extensionName);

            extensions.add(extensionObject);
        }

        infoObject.putArrayWithoutEscaping("extensions", extensions);
View Full Code Here


    }

    @Override
    protected String action() {
        DataServerInfoPackage infoPackage = new DataServerInfoPackage();
        DataServerInfoObject infoObject = new DataServerInfoObject();

        if (this.getInfoObject() == null || this.getInfoObject().get("token") == null
                || this.getInfoObject().get("token").isEmpty()) {

            infoPackage.setStatus(DataServerInfoStatusCode.ARGUMENT_ERROR);
            infoPackage.setStatusMessage("You must have a token");

        } else {
            String adminHost = this.getInfoObject().get("token");

            if (this.extensionObject.isApiAuthTokenCorrect(adminHost)) {
                String upTime = GregorianCalendarHelper.GetDifferenceAsHumanReadableString(
                        new GregorianCalendar(),
                        AIBO.getStartDateTime());

                long usedMB = AIBO.getRAMUsage();

                infoObject.putData("uptime", String.format("Uptime: %s | Memory usage: %d MB", upTime, usedMB));
            } else {
                infoPackage.setStatus(DataServerInfoStatusCode.ARGUMENT_ERROR);
                infoPackage.setStatusMessage(String.format("'%s' unknown token", adminHost));
            }
        }
View Full Code Here

    }

    @Override
    protected String action() {
        DataServerInfoPackage infoPackage = new DataServerInfoPackage();
        DataServerInfoObject infoObject = new DataServerInfoObject();

        if (this.getInfoObject() == null || this.getInfoObject().get("token") == null
                || this.getInfoObject().get("token").isEmpty()) {

            infoPackage.setStatus(DataServerInfoStatusCode.ARGUMENT_ERROR);
            infoPackage.setStatusMessage("You must have a token");

        } else {
            String adminHost = this.getInfoObject().get("token");
            String extensionName = this.getInfoObject().get("extension");

            if (this.extensionObject.isApiAuthTokenCorrect(adminHost)) {
                if (extensionName != null && !extensionName.isEmpty()) {
                    try {
                        if (ExtensionManager.IsExtensionObjectExists(extensionName)) {
                            this.extensionObject.getExtensionManager().addExtensionByName(extensionName);

                            infoObject.putData("answer", "Extension will be loaded automatically soon: " + extensionName);
                        } else {
                            infoObject.putData("answer", "Extension is not exists: " + extensionName);
                        }
                    } catch (ExtensionManagerError e) {
                        infoObject.putData("answer", e.getMessage());
                    }
                } else {
                    infoObject.putData("answer", "Can't add extension: empty string provided");
                }

            } else {
                infoPackage.setStatus(DataServerInfoStatusCode.ARGUMENT_ERROR);
                infoPackage.setStatusMessage(String.format("'%s' unknown token", adminHost));
View Full Code Here

    }

    @Override
    protected String action() {
        DataServerInfoPackage infoPackage = new DataServerInfoPackage();
        DataServerInfoObject infoObject = new DataServerInfoObject();

        if (this.getInfoObject() == null || this.getInfoObject().get("token") == null
                || this.getInfoObject().get("token").isEmpty()) {

            infoPackage.setStatus(DataServerInfoStatusCode.ARGUMENT_ERROR);
            infoPackage.setStatusMessage("You must have a token");

        } else {
            String adminHost = this.getInfoObject().get("token");

            if (this.extensionObject.isApiAuthTokenCorrect(adminHost)) {
                infoObject.putData("answer", "Bot will shut down in 5 seconds");

                AIBO.Shutdown();
            } else {
                infoPackage.setStatus(DataServerInfoStatusCode.ARGUMENT_ERROR);
                infoPackage.setStatusMessage(String.format("'%s' unknown token", adminHost));
View Full Code Here

    }

    @Override
    protected String action() {
        DataServerInfoPackage infoPackage = new DataServerInfoPackage();
        DataServerInfoObject infoObject = new DataServerInfoObject();

        try {
            ArrayList<DataServerInfoObject> games = new ArrayList<DataServerInfoObject>();

            for (Game game : this.extensionObject.getGames()) {
                boolean isTournament = game instanceof Tournament;
                String gameType = game.getGameType();
                List<Player> registeredPlayers = Arrays.asList(game.getPlayers());
                ArrayList<DataServerInfoObject> players = new ArrayList<DataServerInfoObject>();

                for (Player player : registeredPlayers) {
                    DataServerInfoObject playerObject = new DataServerInfoObject();

                    if (!isTournament) {
                        playerObject.putData("nick", player.getNick());
                    }

                    playerObject.putData("game_profile", player.getGameProfile());

                    players.add(playerObject);
                }

                DataServerInfoObject gameObject = new DataServerInfoObject();
                gameObject.putData("is_tournament", isTournament);
                gameObject.putData("game_type", gameType);
                gameObject.putArrayWithoutEscaping("players", players);
                games.add(gameObject);
            }

            infoObject.putArrayWithoutEscaping("games", games);
        } catch (PickupBotError e) {
View Full Code Here

TOP

Related Classes of org.jaibo.api.dataserver.DataServerInfoObject

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.