Exemplo n.º 1
0
 public static void removeSocketIOClient(String sessionId) {
   for (String userId : clientMap.keySet()) {
     Player player = clientMap.get(userId);
     if (player != null && !player.isFlashClient()) {
       for (IOClient socketIOClient : player.getSocketIOClients()) {
         if (socketIOClient.getSessionID().equals(sessionId)) {
           player.getSocketIOClients().remove(socketIOClient);
           if (player.getSocketIOClients().isEmpty()) {
             removePlayer(player.getUserId());
           }
         }
       }
     }
   }
 }
Exemplo n.º 2
0
  public static void removePlayer(String userId) {
    System.out.println("I will remove " + userId + " from the players map.");
    Player player = clientMap.get(userId);
    // TODO: This verification should be unnecessary. Only HTML clients should be stored
    if (player != null && !player.isFlashClient() && player.getDarkstarClient().isConnected()) {
      player
          .getDarkstarClient()
          .logout(false); // Do NOT try to logout forcing it. The code that is written after
      // logout(true) will never be executed. API Bug.
      player.setDarkstarClient(null);
      for (IOClient socketIOClient : player.getSocketIOClients()) {
        socketIOClient.disconnect();
      }
    }

    clientMap.remove(userId);
    System.err.println("I have removed " + userId + " from the players map.");
    System.gc();
  }