コード例 #1
0
 public void sentAdvertise(Advertise advertise) {
   Iterator it = connectedUsers.keySet().iterator();
   while (it.hasNext()) {
     try {
       Object object = it.next();
       ClientInterface client = connectedUsers.get(object);
       client.receiveAdvertis(advertise);
     } catch (RemoteException ex) {
       Logger.getLogger(ServerImplementation.class.getName()).log(Level.SEVERE, null, ex);
     }
   }
 }
コード例 #2
0
  @Override
  public boolean addContact(int user_Id, String eMail) throws RemoteException {
    boolean done = dataBaseOpeartions.addList(user_Id, eMail);

    User user = dataBaseOpeartions.getUser(eMail);
    User user1 = dataBaseOpeartions.getUser(user_Id);

    ClientInterface ci = connectedUsers.get(user.getId());

    ClientInterface me = connectedUsers.get(user_Id);
    if (connectedUsers.containsKey(user.getId()))
      ci.userNotificationadd(user1, me, user1.getStatus());
    if (connectedUsers.containsKey(user_Id)) me.userNotificationadd(user, ci, user.getStatus());

    return done;
  }
コード例 #3
0
  @Override
  public FirstConnect login(String eMail, String passWord, ClientInterface client)
      throws RemoteException {

    User user = dataBaseOpeartions.checkUser(eMail, passWord);

    FirstConnect firstConnect = new FirstConnect();
    if (user != null) {
      try {
        if (!users.contains(user)) users.add(user);
        dataBaseOpeartions.changeStatues(user.getId(), "online");
        user.setStatus("online");
        connectedUsers.put(user.getId(), client);
        ArrayList<User> myFreiends = getContacts(user.getId());
        HashMap<Integer, ClientInterface> myOnlineUser = new HashMap<>();
        for (User user1 : myFreiends) {

          if (connectedUsers.containsKey(user1.getId())) {
            myOnlineUser.put(user1.getId(), connectedUsers.get(user1.getId()));
          }
        }

        Iterator onlineuser = myOnlineUser.keySet().iterator();
        while (onlineuser.hasNext()) {
          Object object = onlineuser.next();
          ClientInterface clients = myOnlineUser.get(object);
          clients.userNotification(
              user.id, client, user.getStatus()); // get online statues away buzy
        }

        firstConnect.setRequestses(dataBaseOpeartions.getfrFriendRequestses(user.id));
        firstConnect.userConnected = myOnlineUser;
        firstConnect.myUser = myFreiends;
        firstConnect.user = user;
        firstConnect.advertise = controller.advertise;
        firstConnect.messages = dataBaseOpeartions.getOfflineMessage(user.id);
      } catch (SQLException ex) {
        Logger.getLogger(ServerImplementation.class.getName()).log(Level.SEVERE, null, ex);
      }

    } else {
      return null;
    }

    //  JOptionPane.showMessageDialog(null, "abdo");
    return firstConnect;
  }
コード例 #4
0
  @Override
  public void changeOnlineStatus(int id, int status) throws RemoteException {
    dataBaseOpeartions.changeonlineStatues(id, status);

    ArrayList<User> myFreiends = getContacts(id);
    HashMap<Integer, ClientInterface> myOnlineUser = new HashMap<>();

    for (User user1 : myFreiends) {

      if (connectedUsers.containsKey(user1.getId())) {
        myOnlineUser.put(user1.getId(), connectedUsers.get(user1.getId()));
      }
    }

    Iterator onlineuser = myOnlineUser.keySet().iterator();
    while (onlineuser.hasNext()) {
      Object object = onlineuser.next();
      ClientInterface clients = myOnlineUser.get(object);
      clients.userNotificationstatues(id, status);
    }
  }
コード例 #5
0
  @Override
  public boolean checkAddContact(int user_Id, String eMail) throws RemoteException {

    User user = dataBaseOpeartions.getUser(eMail);
    User user1 = dataBaseOpeartions.getUser(user_Id);

    if (user != null) {
      if (connectedUsers.containsKey(user.getId())) {
        System.out.println("abdosooasosoos");
        ClientInterface ci = connectedUsers.get(user.getId());
        ci.acceptFriend(user1.getfName(), user1.getEmail());
        return true;

      } else {
        System.out.println("abdo offline");
        dataBaseOpeartions.addRequestFriend(user.getId(), user1.getfName(), user1.getEmail());
        return true;
      }
    } else {
      return false;
    }
  }
コード例 #6
0
 @Override
 public void leaveGroupt(int me, int userid, int chatgroupid) throws RemoteException {
   ClientInterface ci = connectedUsers.get(userid);
   ci.leaveGroupt(me, chatgroupid);
 }
コード例 #7
0
 @Override
 public void receivechatfromGroupingChatt(int id, int groupid, String message)
     throws RemoteException {
   ClientInterface ci = connectedUsers.get(id);
   ci.recivegroupChatFromServer(groupid, message);
 }