Examples of Friend


Examples of userManagement.Friend

           || naarId.startsWith(GameHubModel.GAMEHUB_NAME))) {

          if (naarId.equals(currentUser.getAlias()) && !vanUser.equals(getCurrentUser().getAlias())) {
            Chat.getSingleton().addChat(vanUser);
            try {
              Chat.getSingleton().addChatter(vanUser, new Friend(fromName, vanUser, InetAddress.getByName(fromIp)));
            } catch (UnknownHostException ex) {
              Logger.getLogger(AbstractLoungeModel.class.getName()).log(Level.SEVERE, null, ex);
            }
            Chat.getSingleton().addChatMessage(vanUser, vanUser, text);
          }

        } else if (naarId.equals(GameHubModel.GAMEHUB_NAME + ":")) {

          String[] invoer = networkInput.split(" ");
          int toTeam = Integer.parseInt(invoer[3]);
          String fromUser = invoer[4];

          String message = input[5];

          for (int i = 6; i < input.length; i++) {
            message += " " + input[i];
          }

          Chat.getSingleton().addChatMessage(GameHubModel.GAMEHUB_NAME + ": Team " + toTeam, fromUser, message);

        } else {

          Chat.getSingleton().addChatMessage(naarId, vanUser, text);

        }

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

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

        for (Friend friend : getCurrentUser().getFriends()) {
          if (friend.getName().equals(fromName)) {
            friend.setStatus(FriendStatus.valueOf(status));
          }
        }

        fireStateChanged();

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

        Iterator<Friend> iterator = currentUser.getFriends().iterator();

        while (iterator.hasNext()) {
          Friend friend = iterator.next();

          if (friend.getName().equals(fromName)) {

            if (friend.getStatus() == FriendStatus.OFFLINE) {
              NetworkAdapter.getSingleton().sendMessage("JOINED: " + fromIp, fromIp, fromName);
              Chat.getSingleton().addChatter(GatheringLoungeModel.GATHERINGLOUNGE_NAME, friend);


              friend.setStatus(FriendStatus.IN_GATHERINGLOUNGE);

              fireStateChanged();
            }
          }
        }

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

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

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

          if (friend.getName().equals(fromName)) {
            NetworkAdapter.getSingleton().closeConnection(ip, friend.getName());

            friend.setStatus(FriendStatus.OFFLINE);
            fireStateChanged();
          }
        }

      } else if (networkInput.startsWith(GatheringLoungeModel.REQUEST_PROFILE_TOKEN)) {
View Full Code Here

Examples of userManagement.Friend

  @Override
  public Component getListCellRendererComponent(JList list, Object value,
     int index, boolean isSelected, boolean cellHasFocus) {

    Friend friend = (Friend) value;

    if (isSelected) {
      setBackground(list.getSelectionBackground());
      setForeground(list.getSelectionForeground());
    } else {
      setBackground(list.getBackground());
      setForeground(list.getForeground());
    }

    SquareIcon icon = new SquareIcon(friend.getStatus().getColor(), 10, getHorizontalAlignment(), 10, 10);
    setOpaque(true);
   
    setText(friend.getAlias());
   
    setIcon(icon);
    setIconTextGap(15);

    return this;
View Full Code Here

Examples of userManagement.Friend

     
      abstractLoungeModel.setCurrentUser(user);
      Chat.getSingleton().getChatTabbedModel().editChatter(user);
     
      for (Iterator<Friend> it = abstractLoungeModel.getCurrentUser().getFriends().iterator(); it.hasNext();) {
        Friend friend = it.next();
        NetworkAdapter.getSingleton().sendMessage(AbstractLoungeModel.NAME_CHANGE_TOKEN + " " +
           alias, friend.getIp().getHostAddress(), friend.getName());
      }

    }
  }
View Full Code Here

Examples of userManagement.Friend

  @Override
  public Component getListCellRendererComponent(JList list, Object value,
     int index, boolean isSelected, boolean cellHasFocus) {

    Friend friend = (Friend) value;

    if (isSelected) {
      setBackground(list.getSelectionBackground());
      setForeground(list.getSelectionForeground());
    } else {
      setBackground(list.getBackground());
      setForeground(list.getForeground());
    }
   
    setText(friend.getAlias());
    setOpaque(true);
   
    return this;

  }
View Full Code Here

Examples of userManagement.Friend

    invitedPlayerList = new ArrayList<Player>();

    Iterator<Friend> iterator = currentUser.getFriends().iterator();
    while (iterator.hasNext()) {
      final Friend friend = iterator.next();
      executor.execute(new Runnable() {

        @Override
        public void run() {
          NetworkAdapter.getSingleton().openConnection(friend.getIp().getHostAddress(), friend.getName());
        }
      });
    }

    NetworkAdapter.getSingleton().setNetworkListener(this);
View Full Code Here

Examples of userManagement.Friend

      } 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);
            }
          }
        }

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

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

        JOptionPane.showMessageDialog(null,
           name + " (IP: " + ip + ") has accepted your friend request.", "Friend request accepted",
           JOptionPane.INFORMATION_MESSAGE, null);

        try {
          Friend friend = new Friend(name, alias, Inet4Address.getByName(ip));
          Chat.getSingleton().addChatter(GATHERINGLOUNGE_NAME, friend);
          getCurrentUser().getFriends().add(friend);
          saveUser();

          friend.setStatus(FriendStatus.IN_GATHERINGLOUNGE);
          fireStateChanged();

        } catch (UnknownHostException ex) {
          System.out.println("Zou niet mogen gebeuren.");
        }
View Full Code Here

Examples of userManagement.Friend

    int confirmed = JOptionPane.showConfirmDialog(null,
       name + " (IP: " + ip + ") tries to add you: accept? ", "Friend request",
       JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null);
    if (confirmed == JOptionPane.YES_OPTION) {
      try {
        Friend friend = new Friend(name, alias, Inet4Address.getByName(ip));

        getCurrentUser().getFriends().add(friend);

        saveUser();

        friend.setStatus(FriendStatus.IN_GATHERINGLOUNGE);

        Chat.getSingleton().addChatter(GATHERINGLOUNGE_NAME, friend);
        fireStateChanged();

        NetworkAdapter.getSingleton().sendMessage(FRIEND_ACCEPT_TOKEN + " " + getCurrentUser().getName() + " " + getCurrentUser().getAlias(), ip, port);
View Full Code Here

Examples of userManagement.Friend

    }

  }

  void openEditFriendFrame() {
    Friend friend = (Friend) userList.getSelectedValue();

    editFriendFrame = new JFrame("Edit friend");
    JPanel panel = new EditFriendPanel(friend, this);
    editFriendFrame.setContentPane(panel);
    editFriendFrame.pack();
View Full Code Here

Examples of userManagement.Friend

  }

  public void deleteFriend() {
    Object[] selectedFriends = userList.getSelectedValues();
    for (int i = 0; i < selectedFriends.length; i++) {
      Friend friend = (Friend) selectedFriends[i];
      if (friend.getStatus() != FriendStatus.OFFLINE) {
        NetworkAdapter.getSingleton().sendKillCommand(friend.getIp().getHostAddress(), friend.getName());
        NetworkAdapter.getSingleton().closeConnection(friend.getIp().getHostAddress(), friend.getName());
        Chat.getSingleton().removeChatter(GATHERINGLOUNGE_NAME, friend);
      }
      super.getCurrentUser().getFriends().remove(friend);
    }
View Full Code Here

Examples of userManagement.Friend

           JOptionPane.INFORMATION_MESSAGE);

        // Sluit de connectie en heropent naar het andere IP-adres
        NetworkAdapter.getSingleton().closeConnection(backupIp, friend.getName());

        final Friend vriend = friend;
        executor.execute(new Runnable() {

          @Override
          public void run() {
            NetworkAdapter.getSingleton().openConnection(friendIp, vriend.getName());
          }
        });


      } catch (UnknownHostException ex) {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.