Package userManagement

Examples of userManagement.FriendStatus


        try {
          invitedPlayerIp = Inet4Address.getByName(networkInput.split(" ")[3]);
        } catch (UnknownHostException ex) {
          Logger.getLogger(GatheringLoungeModel.class.getName()).log(Level.SEVERE, null, ex);
        }
        FriendStatus invitedPlayerStatus = FriendStatus.valueOf(networkInput.split(" ")[4]);

        Player player = new Player(invitedPlayerName, invitedPlayerAlias, invitedPlayerIp);
        player.setStatus(invitedPlayerStatus);
        invitedPlayerList.add(player);

      } else if (networkInput.startsWith(RECEIVE_PROFILE_TOKEN)) {

        String[] input = networkInput.split(" ");

        String deel = input[1];

        if (deel.equals("begin")) {

          playerName = input[2];
          playerAlias = input[3];

        } else if (deel.equals("score")) {

          playerScore += input[2];
          for (int i = 3; i < input.length; i++) {
            playerScore += " " + input[i];
          }
          playerScore += "\n";

        } else { // Einde
          showProfile(playerName, playerAlias, playerScore);
        }

      } else if (networkInput.startsWith(NAME_CHANGE_TOKEN)) {

        Iterator<Friend> iterator = super.getCurrentUser().getFriends().iterator();
        while (iterator.hasNext()) {
          Friend friend = iterator.next();

          String newAlias = networkInput.split(" ")[1];

          if (friend.getName().equals(fromName)) {
            Chat.getSingleton().getChatTabbedModel().editChatter(friend, friend.getAlias(), newAlias);
            friend.setAlias(newAlias);
          }
        }

        saveUser();
        fireStateChanged();

      } else if (networkInput.startsWith(FRIEND_REQUEST_TOKEN)) {
        Iterator<Friend> iterator = super.getCurrentUser().getFriends().iterator();
        boolean exists = false;

        String name = networkInput.split(" ")[1];
        String alias = networkInput.split(" ")[2];

        Friend friend = null;

        while (iterator.hasNext() && !exists) {
          friend = iterator.next();

          if (friend.getName().equals(fromName)) {
            exists = true;
          }
        }

        if (!exists) {  // maak vriend aan
          openAddFriendFrame(name, alias, fromIp, port);
        } else {
          NetworkAdapter.getSingleton().sendMessage(FRIEND_ACCEPT_TOKEN + " " + getCurrentUser().getName() + " " + getCurrentUser().getAlias(), fromIp, port);
          friend.setStatus(FriendStatus.IN_GATHERINGLOUNGE);
          Chat.getSingleton().addChatter(GATHERINGLOUNGE_NAME, friend);
          fireStateChanged();
        }

      } else if (networkInput.startsWith("LEFT:")) {

        for (Friend friend : getCurrentUser().getFriends()) {
          if (friend.getName().equals(fromName)) {
            Chat.getSingleton().removeChatter(GATHERINGLOUNGE_NAME, friend);
          }
        }

      } else if (networkInput.startsWith(GameLoungeModel.STATUS_CHANGE_TOKEN)) {

        for (Friend friend : getCurrentUser().getFriends()) {
          if (friend.getName().equals(fromName)) {

            FriendStatus friendStatus = friend.getStatus();

            if (friendStatus == FriendStatus.IN_GATHERINGLOUNGE) {
              Chat.getSingleton().addChatter(GATHERINGLOUNGE_NAME, friend);
            }
          }
View Full Code Here


            Player invitedPlayer = ite.next();

            if (invitedPlayer.getName().equals(fromName)) {
              playerList.add(invitedPlayer);
              FriendStatus status = FriendStatus.valueOf(networkInput.split(" ")[2]);
              invitedPlayer.setStatus(status);

              Chat.getSingleton().addChatter(GAMELOUNGE_NAME, invitedPlayer);

              String message = GAME_CHANGED_TOKEN + "@@@";

              message += gameFileName + "@@@";
              message += gameName + "@@@";
              message += gamePlayers + "@@@";
              message += gameTeams + "@@@";
              message += gameDescription;

              NetworkAdapter.getSingleton().sendMessage(message, fromIp, port);

              NetworkAdapter.getSingleton().sendMessage(JOIN_TOKEN + " " + getCurrentUser().getName() + " " + getCurrentUser().getStatus(), fromIp, port);

              fireStateChanged();

              exists = true;
            }

          }

        }

      } else if (networkInput.startsWith(GatheringLoungeModel.I_HAVE_INVITED_TOKEN)) {

        String invitedPlayerName = networkInput.split(" ")[1];
        String invitedPlayerAlias = networkInput.split(" ")[2];
        InetAddress invitedPlayerIp = null;
        try {
          invitedPlayerIp = Inet4Address.getByName(networkInput.split(" ")[3]);
        } catch (UnknownHostException ex) {
          Logger.getLogger(GatheringLoungeModel.class.getName()).log(Level.SEVERE, null, ex);
        }
        int invitedPlayerPort = Integer.parseInt(networkInput.split(" ")[4]);
        FriendStatus invitedPlayerStatus = FriendStatus.valueOf(networkInput.split(" ")[5]);

        Player player = new Player(invitedPlayerName, invitedPlayerAlias, invitedPlayerIp);
        player.setStatus(invitedPlayerStatus);
        invitedPlayerList.add(player);

      } else if (networkInput.startsWith(GAME_STARTED_TOKEN)) {

        if (getCurrentUser().getStatus() == FriendStatus.IN_GAMELOUNGE) {

          leaveGameLounge();

        } else {
          receivingFase = true;

          Chat.getSingleton().addChatMessage(GAMELOUNGE_NAME, "GameInfo", "Teams set. All receive the game!");

          getCurrentUser().setStatus(FriendStatus.IN_GAMELOUNGE);

          for (Friend friend : getCurrentUser().getFriends()) {
            NetworkAdapter.getSingleton().sendMessage(AbstractLoungeModel.STATUS_CHANGE_TOKEN + " " + getCurrentUser().getStatus(),
               friend.getIp().getHostAddress(), friend.getName());
          }

          for (Player player : playerList) {
            if (player.getStatus() != FriendStatus.IS_HOSTING) {
              player.setStatus(FriendStatus.IN_GAMELOUNGE);
            }
          }

          amountReady = 1;

          fireStateChanged();

          requestGame();
        }

      } else if (networkInput.startsWith(KICK_TOKEN)) {

        leaveGameLounge();

      } else if (networkInput.startsWith(STATUS_CHANGE_TOKEN)) {

        String status = networkInput.split(" ")[1];
        FriendStatus newState = FriendStatus.valueOf(status);

        for (Friend friend : playerList) {

          if (friend.getName().equals(fromName)) {
View Full Code Here

TOP

Related Classes of userManagement.FriendStatus

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.