@RequestMapping(value = CLIENT_DISCONNECT_PATH, method = RequestMethod.DELETE)
 public @ResponseBody int removeClient(
     @RequestParam(value = "username") String uName, HttpServletResponse response) {
   try {
     if (!user_vidNameMap.containsKey(uName)) {
       response.setStatus(402); // client not connected
       return 0;
     }
     System.out.println("Disconnecting " + uName);
     removeUser(uName);
     userAliveMap.remove(uName);
     return ACK;
   } catch (Exception e) {
     System.err.println(e.getMessage());
     return FAILED;
   }
 }
Beispiel #2
0
  void updateAddress64(long address64) {
    synchronized (this) {
      if (serialNumber != null && serialNumber.longValue() == address64) {
        return;
      }

      if (serialNumber != null) {
        knownNodes.remove(serialNumber);
      }

      if (address64 != -1 && address64 != 0) {
        serialNumber = new Long(address64);
        knownNodes.put(serialNumber, this);
        sendMessage("SERIALNO");
        sendStaticMessage("SERIALNO");
      }
    }
  }
Beispiel #3
0
  private static void queryNotifyCallbackHandler(int handlerNum, int msgInstance, int byteArray) {
    String hashKey = Integer.toString(handlerNum);
    handlerHashData handlerData = (handlerHashData) msgHashTable.get(hashKey);

    msgHashTable.remove(hashKey);
    if (handlerData != null) {
      Object object;
      try {
        object =
            unmarshallMsgData(
                IPC_msgInstanceFormatter(msgInstance), byteArray, handlerData.dataClass);
        handlerData.handler.handle(new MSG_INSTANCE(msgInstance), object);
      } catch (Exception e) {
        handleException("queryNotifyCallbackHandler", IPC_msgInstanceName(msgInstance), e);
      }
    } else
      System.out.println(
          "Ooops -- no query notification handler for " + IPC_msgInstanceName(msgInstance));
  }
 @Scheduled(fixedDelay = SCHEDULED_CHECK)
 public void checkActiveClients() {
   Set<String> users = user_vidNameMap.keySet();
   Iterator<String> it = users.iterator();
   long time = System.currentTimeMillis();
   int count = 0;
   while (it.hasNext()) {
     count++;
     String user = it.next();
     if (user == null) continue;
     if (userAliveMap.containsKey(user)) {
       if (userAliveMap.get(user).longValue() < time) {
         removeUser(user);
         userAliveMap.remove(user);
       }
     } else {
       throw new RuntimeException("user in user-vid map but not in user-alive map");
     }
   }
   // System.out.println("Debug: Scheduled Check count:"+count+" user
   // count:"+user_vidNameMap.size());
   System.gc();
 }