Package mage.view

Examples of mage.view.ChatMessage


      }
      else if (callback.getMethod().equals("watchGame")) {
        watchGame((UUID) callback.getData());
      }
      else if (callback.getMethod().equals("chatMessage")) {
        ChatMessage message = (ChatMessage) callback.getData();
        ChatPanel panel = session.getChats().get(message.getChatId());
        if (panel != null)
          panel.receiveMessage(message.getMessage(), message.getColor());
      }
      else if (callback.getMethod().equals("replayInit")) {
        session.getGame().init((GameView) callback.getData());
      }
      else if (callback.getMethod().equals("replayDone")) {
        session.getGame().modalMessage((String) callback.getData());
        session.getGame().hideGame();
      }
      else if (callback.getMethod().equals("replayUpdate")) {
        session.getGame().updateGame((GameView) callback.getData());
      }
      else if (callback.getMethod().equals("gameInit")) {
        session.getGame().init((GameView) callback.getData());
        session.ack("gameInit");
      }
      else if (callback.getMethod().equals("gameOver")) {
        session.getGame().modalMessage((String) callback.getData());
        session.getGame().hideGame();
      }
      else if (callback.getMethod().equals("gameAsk")) {
        GameClientMessage message = (GameClientMessage) callback.getData();
        session.getGame().ask(message.getMessage(), message.getGameView());
      }
      else if (callback.getMethod().equals("gameTarget")) {
        GameClientMessage message = (GameClientMessage) callback.getData();
        session.getGame().pickTarget(message.getMessage(), message.getCardsView(), message.getGameView(), message.getTargets(), message.isFlag());
      }
      else if (callback.getMethod().equals("gameSelect")) {
        GameClientMessage message = (GameClientMessage) callback.getData();
        session.getGame().select(message.getMessage(), message.getGameView());
      }
      else if (callback.getMethod().equals("gameChooseAbility")) {
        session.getGame().pickAbility((AbilityPickerView) callback.getData());
      }
      else if (callback.getMethod().equals("gameChoose")) {
        GameClientMessage message = (GameClientMessage) callback.getData();
        session.getGame().getChoice(message.getMessage(), message.getStrings());
      }
      else if (callback.getMethod().equals("gamePlayMana")) {
        GameClientMessage message = (GameClientMessage) callback.getData();
        session.getGame().playMana(message.getMessage(), message.getGameView());
      }
      else if (callback.getMethod().equals("gamePlayXMana")) {
        GameClientMessage message = (GameClientMessage) callback.getData();
        session.getGame().playXMana(message.getMessage(), message.getGameView());
      }
      else if (callback.getMethod().equals("gameSelectAmount")) {
        GameClientMessage message = (GameClientMessage) callback.getData();
        session.getGame().getAmount(message.getMin(), message.getMax(), message.getMessage());
      }
      else if (callback.getMethod().equals("gameReveal")) {
        GameClientMessage message = (GameClientMessage) callback.getData();
        session.getGame().revealCards(message.getMessage(), message.getCardsView());
      }
      else if (callback.getMethod().equals("gameUpdate")) {
        session.getGame().updateGame((GameView) callback.getData());
      }
      else if (callback.getMethod().equals("gameInform")) {
        if (callback.getMessageId() > messageId) {
          GameClientMessage message = (GameClientMessage) callback.getData();
          session.getGame().inform(message.getMessage(), message.getGameView());
        }
        else {
          logger.warning("message out of sequence - ignoring");
        }
      }
View Full Code Here


    Calendar cal = new GregorianCalendar();
    final String msg = timeFormatter.format(cal.getTime()) + " " + userName + ":" + message;
    for (UUID sessionId: clients.keySet()) {
      Session session = SessionManager.getInstance().getSession(sessionId);
      if (session != null)
        session.fireCallback(new ClientCallback("chatMessage", new ChatMessage(chatId, msg, color)));
      else
        kill(sessionId);
    }
  }
View Full Code Here

            execute("sendBroadcastMessage", sessionId, new Action() {
                @Override
                public void execute() {
                    for (User user : UserManager.getInstance().getUsers()) {
                        if (message.toLowerCase(Locale.ENGLISH).startsWith("warn")) {
                            user.fireCallback(new ClientCallback("serverMessage", null, new ChatMessage("SERVER", message, null, MessageColor.RED)));
                        } else {
                            user.fireCallback(new ClientCallback("serverMessage", null, new ChatMessage("SERVER", message, null, MessageColor.BLUE)));
                        }
                    }
                }
            }, true);
        }
View Full Code Here

        }
    }

    public boolean broadcastInfoToUser(User toUser, String message) {
        if (clients.containsKey(toUser.getId())) {
            toUser.fireCallback(new ClientCallback("chatMessage", chatId, new ChatMessage(null, message, timeFormatter.format(new Date()), MessageColor.BLUE, MessageType.USER_INFO, null)));
            return true;
        }
        return false;
    }
View Full Code Here

    }

    public boolean broadcastWhisperToUser(User fromUser, User toUser, String message) {
        if (clients.containsKey(toUser.getId())) {
            toUser.fireCallback(new ClientCallback("chatMessage", chatId,
                    new ChatMessage(new StringBuilder("Whisper from ").append(fromUser.getName()).toString(), message, timeFormatter.format(new Date()), MessageColor.YELLOW, MessageType.WHISPER, SoundToPlay.PlayerWhispered)));
            if (clients.containsKey(fromUser.getId())) {
                fromUser.fireCallback(new ClientCallback("chatMessage", chatId,
                        new ChatMessage(new StringBuilder("Whisper to ").append(toUser.getName()).toString(), message, timeFormatter.format(new Date()), MessageColor.YELLOW, MessageType.WHISPER, null)));
                return true;
            }
        }
        return false;
    }
View Full Code Here

            final String username = userName;
            logger.trace("Broadcasting '" + msg + "' for " + chatId);
            for (UUID userId: clients.keySet()) {
                User user = UserManager.getInstance().getUser(userId);
                if (user != null) {
                    user.fireCallback(new ClientCallback("chatMessage", chatId, new ChatMessage(username, msg, time, color, messageType, soundToPlay)));
                }
                else {
                    logger.error("User not found but connected to chat - userId: " + userId + "  chatId: " + chatId);
                    clientsToRemove.add(userId);
                    remove = true;
View Full Code Here

                        case "watchGame":
                            watchGame(callback.getObjectId());
                            break;
                        case "chatMessage":
                            {
                                ChatMessage message = (ChatMessage) callback.getData();
                                ChatPanel panel = MageFrame.getChat(callback.getObjectId());
                                if (panel != null) {
                                    // play the to the message connected sound
                                    if (message.getSoundToPlay() != null) {
                                        switch (message.getSoundToPlay()) {
                                            case PlayerLeft:
                                                AudioManager.playPlayerLeft();
                                                break;
                                            case PlayerQuitTournament:
                                                AudioManager.playPlayerQuitTournament();
                                                break;
                                            case PlayerSubmittedDeck:
                                                AudioManager.playPlayerSubmittedDeck();
                                                break;
                                            case PlayerWhispered:
                                                AudioManager.playPlayerWhispered();
                                                break;
                                        }
                                    }
                                    // send start message to chat if not done yet
                                    if (!panel.isStartMessageDone()) {
                                        createChatStartMessage(panel);
                                    }
                                    // send the message to subchat if exists and it's not a game message
                                    if (!message.getMessageType().equals(MessageType.GAME) && panel.getConnectedChat() != null) {
                                        panel.getConnectedChat().receiveMessage(message.getUsername(), message.getMessage(), message.getTime(), message.getMessageType(), ChatMessage.MessageColor.BLACK);
                                    } else {
                                        panel.receiveMessage(message.getUsername(), message.getMessage(), message.getTime(), message.getMessageType(),  message.getColor());
                                    }
                                   
                                }       break;
                            }
                        case "serverMessage":
                            if (callback.getData() != null) {
                                ChatMessage message = (ChatMessage) callback.getData();
                                if (message.getColor().equals(ChatMessage.MessageColor.RED)) {
                                    JOptionPane.showMessageDialog(null, message.getMessage(), "Server message", JOptionPane.WARNING_MESSAGE);
                                } else {
                                    JOptionPane.showMessageDialog(null, message.getMessage(), "Server message", JOptionPane.INFORMATION_MESSAGE);
                                }
                            }   break;
                        case "joinedTable":
                            {
                                TableClientMessage message = (TableClientMessage) callback.getData();
                                joinedTable(message.getRoomId(), message.getTableId(), message.getFlag());
                                break;
                            }
                        case "replayInit":
                            {
                                GamePanel panel = MageFrame.getGame(callback.getObjectId());
                                if (panel != null) {
                                    panel.init((GameView) callback.getData());
                                }       break;
                            }
                        case "replayDone":
                            {
                                GamePanel panel = MageFrame.getGame(callback.getObjectId());
                                if (panel != null) {
                                    panel.endMessage((String) callback.getData(), callback.getMessageId());
                                }       break;
                            }
                        case "replayUpdate":
                            {
                                GamePanel panel = MageFrame.getGame(callback.getObjectId());
                                if (panel != null) {
                                    panel.updateGame((GameView) callback.getData());
                                }       break;
                            }
                        case "gameInit":
                            {
                                GamePanel panel = MageFrame.getGame(callback.getObjectId());
                                if (panel != null) {
                                    panel.init((GameView) callback.getData());
                                }       break;
                            }
                        case "gameOver":
                            {
                                GamePanel panel = MageFrame.getGame(callback.getObjectId());
                                if (panel != null) {
                                    panel.endMessage((String) callback.getData(), callback.getMessageId());
                                }       break;
                            }
                        case "gameError":
                            frame.showErrorDialog("Game Error", (String) callback.getData());
                            break;
                        case "gameAsk":
                            {
                                GameClientMessage message = (GameClientMessage) callback.getData();
                                GamePanel panel = MageFrame.getGame(callback.getObjectId());
                                if (panel != null) {
                                    panel.ask(message.getMessage(), message.getGameView(), callback.getMessageId());
                                }       break;
                            }
                        case "gameTarget": // e.g. Pick triggered ability
                            {
                                GameClientMessage message = (GameClientMessage) callback.getData();
                                GamePanel panel = MageFrame.getGame(callback.getObjectId());
                                if (panel != null) {
                                    panel.pickTarget(message.getMessage(), message.getCardsView(), message.getGameView(),
                                            message.getTargets(), message.isFlag(), message.getOptions(), callback.getMessageId());
                                }       break;
                            }
                        case "gameSelect":
                            {
                                GameClientMessage message = (GameClientMessage) callback.getData();
                                GamePanel panel = MageFrame.getGame(callback.getObjectId());
                                if (panel != null) {
                                    panel.select(message.getMessage(), message.getGameView(), callback.getMessageId(), message.getOptions());
                                }       break;
                            }
                        case "gameChooseAbility":
                            {
                                GamePanel panel = MageFrame.getGame(callback.getObjectId());
                                if (panel != null) {
                                    panel.pickAbility((AbilityPickerView) callback.getData());
                                }       break;
                            }
                        case "gameChoosePile":
                            {
                                GameClientMessage message = (GameClientMessage) callback.getData();
                                GamePanel panel = MageFrame.getGame(callback.getObjectId());
                                if (panel != null) {
                                    panel.pickPile(message.getMessage(), message.getPile1(), message.getPile2());
                                }       break;
                            }
                        case "gameChooseChoice":
                            {
                                GameClientMessage message = (GameClientMessage) callback.getData();
                                GamePanel panel = MageFrame.getGame(callback.getObjectId());

                                if (panel != null) {
                                    panel.getChoice(message.getChoice(), callback.getObjectId());
                                }       break;
                            }
                        case "gamePlayMana":
                            {
                                GameClientMessage message = (GameClientMessage) callback.getData();
                                GamePanel panel = MageFrame.getGame(callback.getObjectId());
                                if (panel != null) {
                                    panel.playMana(message.getMessage(), message.getGameView(), callback.getMessageId());
                                }       break;
                            }
                        case "gamePlayXMana":
                            {
                                GameClientMessage message = (GameClientMessage) callback.getData();
                                GamePanel panel = MageFrame.getGame(callback.getObjectId());
                                if (panel != null) {
                                    panel.playXMana(message.getMessage(), message.getGameView(), callback.getMessageId());
                                }       break;
                            }
                        case "gameSelectAmount":
                            {
                                GameClientMessage message = (GameClientMessage) callback.getData();
                                GamePanel panel = MageFrame.getGame(callback.getObjectId());
                                if (panel != null) {
                                    panel.getAmount(message.getMin(), message.getMax(), message.getMessage());
                                }       break;
                            }
                        case "gameUpdate":
                            {
                                GamePanel panel = MageFrame.getGame(callback.getObjectId());
                                if (panel != null) {
                                    panel.updateGame((GameView) callback.getData());
                                }       break;
                            }
                        case "endGameInfo":
                            MageFrame.getInstance().showGameEndDialog((GameEndView) callback.getData());
                            break;
                        case "showUserMessage":
                            List<String> messageData = (List<String>) callback.getData();
                            if (messageData.size() == 2) {
                                JOptionPane.showMessageDialog(null, messageData.get(1), messageData.get(0), JOptionPane.WARNING_MESSAGE);
                            }   break;
                        case "gameInform":
                            if (callback.getMessageId() > gameInformMessageId) {
                                {
                                    GameClientMessage message = (GameClientMessage) callback.getData();
                                    GamePanel panel = MageFrame.getGame(callback.getObjectId());
                                    if (panel != null) {
                                        panel.inform(message.getMessage(), message.getGameView(), callback.getMessageId());
                                    }
                                }
// no longer needed because phase skip handling on server side now
                            } else {
                                logger.warn(new StringBuilder("message out of sequence - ignoring").append("MessageId = ").append(callback.getMessageId()).append(" method = ").append(callback.getMethod()));
                                //logger.warn("message out of sequence - ignoring");
                            }
                            gameInformMessageId = messageId;
                            break;
                        case "gameInformPersonal":
                            {
                                GameClientMessage message = (GameClientMessage) callback.getData();
                                GamePanel panel = MageFrame.getGame(callback.getObjectId());
                                if (panel != null) {
                                    JOptionPane.showMessageDialog(panel, message.getMessage(), "Game message",
                                            JOptionPane.INFORMATION_MESSAGE);
                                }       break;
                            }
                        case "sideboard":
                            {
                                TableClientMessage message = (TableClientMessage) callback.getData();
                                DeckView deckView = message.getDeck();
                                Deck deck = DeckUtil.construct(deckView);
                                if (message.getFlag()) {
                                    construct(deck, message.getTableId(), message.getTime());
                                } else {
                                    sideboard(deck, message.getTableId(), message.getTime());
                                }       break;
                            }
                        case "construct":
                            {
                                TableClientMessage message = (TableClientMessage) callback.getData();
                                DeckView deckView = message.getDeck();
                                Deck deck = DeckUtil.construct(deckView);
                                construct(deck, message.getTableId(), message.getTime());
                                break;
                            }
                        case "draftOver":
                            MageFrame.removeDraft(callback.getObjectId());
                            break;
                        case "draftPick":
                            {
                                DraftClientMessage message = (DraftClientMessage) callback.getData();
                                DraftPanel panel = MageFrame.getDraft(callback.getObjectId());
                                if (panel != null) {
                                    panel.loadBooster(message.getDraftPickView());
                                }       break;
                            }
                        case "draftUpdate":
                            {
                                DraftPanel panel = MageFrame.getDraft(callback.getObjectId());
                                if (panel != null) {
                                    panel.updateDraft((DraftView) callback.getData());
                                }
                                break;
                            }
                        case "draftInform":
//                            if (callback.getMessageId() > messageId) {
                            {
                                DraftClientMessage message = (DraftClientMessage) callback.getData();
                            }
//                            } else {
//                                logger.warn("message out of sequence - ignoring");
//                            }
//                            break;
                        case "draftInit":
                            {
                                DraftClientMessage message = (DraftClientMessage) callback.getData();
                                DraftPanel panel = MageFrame.getDraft(callback.getObjectId());
                                if (panel != null) {
                                    panel.loadBooster(message.getDraftPickView());
                                }       break;
                            }
                        case "tournamentInit":
                            break;
                    }
View Full Code Here

TOP

Related Classes of mage.view.ChatMessage

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.