@RequestMapping(value = PS_DELETE_CLIENT, method = RequestMethod.DELETE)
 public @ResponseBody int ps_DeleteClient(@RequestParam(USER_PARAMETER) String user) {
   try {
     activeUsers.remove(user);
     return ACK;
   } catch (Exception e) {
     System.err.println("" + e.getMessage());
     return FAILED;
   }
 }
    public void handleStreamEvent(StreamEvent event) {
      if (event.eventType == StreamEvent.Type.STREAM_PREPARED) {
        SessionInfo session = ((StreamEvent.SessionPreparedEvent) event).session;
        sessionsByHost.put(session.peer, session);
      } else if (event.eventType == StreamEvent.Type.FILE_PROGRESS) {
        ProgressInfo progressInfo = ((StreamEvent.ProgressEvent) event).progress;

        // update progress
        Set<ProgressInfo> progresses = progressByHost.get(progressInfo.peer);
        if (progresses == null) {
          progresses = Sets.newSetFromMap(new ConcurrentHashMap<ProgressInfo, Boolean>());
          progressByHost.put(progressInfo.peer, progresses);
        }
        if (progresses.contains(progressInfo)) progresses.remove(progressInfo);
        progresses.add(progressInfo);

        StringBuilder sb = new StringBuilder();
        sb.append("\rprogress: ");

        long totalProgress = 0;
        long totalSize = 0;
        for (Map.Entry<InetAddress, Set<ProgressInfo>> entry : progressByHost.entrySet()) {
          SessionInfo session = sessionsByHost.get(entry.getKey());

          long size = session.getTotalSizeToSend();
          long current = 0;
          int completed = 0;
          for (ProgressInfo progress : entry.getValue()) {
            if (progress.currentBytes == progress.totalBytes) completed++;
            current += progress.currentBytes;
          }
          totalProgress += current;
          totalSize += size;
          sb.append("[").append(entry.getKey());
          sb.append(" ").append(completed).append("/").append(session.getTotalFilesToSend());
          sb.append(" (").append(size == 0 ? 100L : current * 100L / size).append("%)] ");
        }
        long time = System.nanoTime();
        long deltaTime = Math.max(1L, TimeUnit.NANOSECONDS.toMillis(time - lastTime));
        lastTime = time;
        long deltaProgress = totalProgress - lastProgress;
        lastProgress = totalProgress;

        sb.append("[total: ")
            .append(totalSize == 0 ? 100L : totalProgress * 100L / totalSize)
            .append("% - ");
        sb.append(mbPerSec(deltaProgress, deltaTime)).append("MB/s");
        sb.append(" (avg: ")
            .append(mbPerSec(totalProgress, TimeUnit.NANOSECONDS.toMillis(time - start)))
            .append("MB/s)]");

        System.out.print(sb.toString());
      }
    }
 @RequestMapping(value = PS_DELETE_MULTI_CLIENT, method = RequestMethod.POST)
 public @ResponseBody int ps_DeleteMultipleClient(@RequestBody String[] user) {
   try {
     for (int i = 0; i < user.length; i++) {
       activeUsers.remove(user[i]);
     }
     return ACK;
   } catch (Exception e) {
     System.err.println(e.getMessage());
     return FAILED;
   }
 }
  private void removeUser(String user) {
    int count = 0;

    if (user_vidNameMap.containsKey(user)) {
      Set<String> vids = user_vidNameMap.get(user);
      Iterator<String> it = vids.iterator();
      while (it.hasNext()) {
        removeFromvidName_UserMap(user, it.next());
      }
      vids.clear();
      user_vidNameMap.remove(user);
    }
    activeUsers.remove(user);
    int ans = masterService.psDisConnectClient(hostAdder, user);
    while (ans != ACK) {
      if (count > 10) throw new RuntimeException("Time out in removing user from MS");
      reconnectToMS();
      ans = masterService.psDisConnectClient(hostAdder, user);
      count++;
    }
    System.out.println("User " + user + " removed.");
  }
示例#5
0
 /**
  * Removes the given audio event listener from being notified of future audio events, if it was
  * present. If not present, has no effect.
  */
 public static void removeAudioEventListener(AudioEventListener listener) {
   listeners.remove(listener);
 }