Beispiel #1
0
  /**
   * Adds a new user to the list of users that should receive a media stream.
   *
   * @param user The user to stream media to
   * @return True if the user was successfully added, false if not (duplicate record existed)
   */
  public boolean addUser(User user) {
    if (user == null) return false;

    synchronized (clients) {
      for (User u : clients) {
        if (u == user) {
          return false;
        }
      }
      clients.add(user);
      log.info("Added user \"" + user.getUsername() + "\" to streaming media clients.");
      return true;
    }
  }
Beispiel #2
0
 /**
  * Removes a user from the list of users that should receive a media stream.
  *
  * @param user The user to stop streaming media to
  * @return True if the user was successfully removed, false if not (user could not be found in
  *     existing client list)
  */
 public boolean removeUser(User user) {
   synchronized (clients) {
     log.info("Removing user \"" + user.getUsername() + "\" from streaming media clients.");
     return clients.remove(user);
   }
 }