Package server.common

Examples of server.common.Message


        }
        return response;
    }

    public synchronized Message exchangeTile(String playerID, String tiles) {
        Message response = null;
        try {
            response = game.exchangeTile(playerID, tiles);

            if (response == null) {
                throw new GameException(GameException.typeErr.SYSKO);
View Full Code Here


        }
        return response;
    }

    public synchronized Message switchTile(String playerID, String position) {
        Message response = null;
        try {
            response = game.switchTile(playerID, position);

            if (response == null) {
                throw new GameException(GameException.typeErr.SYSKO);
View Full Code Here

     *
     * @param e
     * @return a message instance with specific header.
     */
    private synchronized Message processError(GameException e) {
        Message error = null;
        switch (e.getError()) {
            case SYSKO:
                error = new Message(Message.SYSKO, "");
                outputPrint("Server error : System KO.");
                break;
            case PLAYER_EXISTS:
                error = new Message(Message.PLAYER_EXISTS, "");
                outputPrint("Server error : Player already exists.");
                break;
            case PLAYER_NOT_EXISTS:
                error = new Message(Message.PLAYER_NOT_EXISTS, "");
                outputPrint("Server error : Player does not yet exist.");
                break;
            case LOGIN_ERROR:
                error = new Message(Message.LOGIN_ERROR, "");
                outputPrint("Server error : Login error.");
                break;
            case LOGOUT_ERROR:
                error = new Message(Message.LOGOUT_ERROR, "");
                outputPrint("Server error : Logout error.");
                break;
            case PLAYER_NOT_LOGGED:
                error = new Message(Message.PLAYER_NOT_LOGGED, "");
                outputPrint("Server error : The current player does not yet logged.");
                break;
            case LOAD_GAME_LIST_ERROR:
                error = new Message(Message.LOAD_GAME_LIST_ERROR, "");
                outputPrint("Server error : The current player does not yet any plays saved on the server.");
                break;
            case LOAD_GAME_ERROR:
                error = new Message(Message.LOAD_GAME_ERROR, "");
                outputPrint("Server error : The current player can not load play saved on the server.");
                break;
            case XML_FILE_NOT_EXISTS:
                error = new Message(Message.LOAD_GAME_ERROR, ""); // Send this error because the client side must ignore how data are saved on the server. This error concerned a data loading error. (from file or DB, ...)
                outputPrint("Server error : The current player can not load play saved on the server.");
                break;
            case NEW_GAME_ANONYM_ERROR:
                error = new Message(Message.NEW_GAME_ANONYM_ERROR, "");
                outputPrint("Server error : The current anonymous player is already logged on the server. No play may be created.");
                break;
            case DELETE_ANONYM_ERROR:
                error = new Message(Message.DELETE_ANONYM_ERROR, "");
                outputPrint("Server error : The current anonymous player does not yet logged on the server. No play to remove.");
                break;
            case GAME_IDENT_ERROR:
                error = new Message(Message.GAME_IDENT_ERROR, "");
                outputPrint("Server error : The current player does not yet logged on the server or can't play at specific game.");
                break;
            case TILE_EXCHANGE_ERROR:
                error = new Message(Message.TILE_EXCHANGE_ERROR, "");
                outputPrint("Server error : Something went wrong with the tile exchange. Don't ask me, I don't know what.");
                break;
        }
        return error;
    }
View Full Code Here

*/
public abstract class Game implements IGame {

    @Override
    public Message newAccount(String pl_name, String pl_pwd) throws GameException {
        Message response = createAccount(pl_name, pl_pwd);
        switch (response.getHeader()) {
            case Message.NEW_ACCOUNT_SUCCESS:
                return response;
            case Message.NEW_ACCOUNT_ERROR:
                throw new GameException(GameException.typeErr.PLAYER_EXISTS);
        }
View Full Code Here

        return null;
    }

    @Override
    public Message login(String pl_name, String pl_pwd) throws GameException {
        Message response = loginProcess(pl_name, pl_pwd);
        switch (response.getHeader()) {
            case Message.LOGIN_SUCCESS:
                return response;
            case Message.LOGIN_ERROR:
                throw new GameException(GameException.typeErr.LOGIN_ERROR);
            case Message.PLAYER_NOT_EXISTS:
View Full Code Here

        return null;
    }

    @Override
    public Message logout(String pl_id) throws GameException {
        Message response = logoutProcess(pl_id);
        switch (response.getHeader()) {
            case Message.LOGOUT_SUCCESS:
                return response;
            case Message.LOGOUT_ERROR:
                throw new GameException(GameException.typeErr.LOGOUT_ERROR);
        }
View Full Code Here

    }

    // Game -  plays actions
    @Override
    public Message createNewPlay(String pl_id) throws GameException {
        Message response = createNewGame(pl_id);
        switch (response.getHeader()) {
            case Message.NEW_GAME_SUCCESS:
                return response;
            case Message.PLAYER_NOT_LOGGED:
                throw new GameException(GameException.typeErr.PLAYER_NOT_LOGGED);
        }
View Full Code Here

        return null;
    }

    @Override
    public Message createNewAnonymPlay(String pl_id) throws GameException {
        Message response = createNewAnonymGame(pl_id);
        switch (response.getHeader()) {
            case Message.NEW_GAME_ANONYM_SUCCESS:
                return response;
            case Message.NEW_GAME_ANONYM_ERROR:
                throw new GameException(GameException.typeErr.NEW_GAME_ANONYM_ERROR);
        }
View Full Code Here

     * @param pl_id
     * @return
     * @throws GameException
     */
    public Message loadPlayList(String pl_id) throws GameException {
        Message response = loadPlayLister(pl_id);
        switch (response.getHeader()) {
            case Message.LOAD_GAME_LIST_SUCCESS:
                return response;
            case Message.LOAD_GAME_LIST_ERROR:
                throw new GameException(GameException.typeErr.LOAD_GAME_LIST_ERROR);
            case Message.PLAYER_NOT_LOGGED:
View Full Code Here

        }
        return null;
    }

    public Message loadSavedPlay(String pl_id, String ga_id) throws GameException {
        Message response = loadPlay(pl_id, ga_id);
        switch (response.getHeader()) {
            case Message.LOAD_GAME_SUCCESS:
                return response;
            case Message.LOAD_GAME_ERROR:
                throw new GameException(GameException.typeErr.LOAD_GAME_ERROR);
            case Message.PLAYER_NOT_LOGGED:
View Full Code Here

TOP

Related Classes of server.common.Message

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.