Exemple #1
0
  /**
   * Provede prihlaseni uzivatele Odesle mu seznam aktualnich uzivatelu a r ozesle informaci o
   * prihlaseni ostatnim uzivatelum
   *
   * @param serverThread Vlakno serveru
   */
  public synchronized boolean login(ServerThread serverThread) {
    if (clients.containsKey(serverThread.getLogin().toLowerCase())) {
      return false;
    }

    // Send login info to other clients
    Enumeration<ServerThread> e = getClients().elements();
    while (e.hasMoreElements()) {
      e.nextElement().userLogin(serverThread.getLogin());
    }

    // Send users list to client
    Enumeration<ServerThread> e2 = getClients().elements();
    while (e2.hasMoreElements()) {
      ServerThread serverThread2 = e2.nextElement();
      serverThread.userLogin(serverThread2.getLogin());
      if (serverThread2.getServerGame() != null) {
        serverThread.userInGame(serverThread2.getLogin());
      }
    }

    // Append client to list
    clients.put(serverThread.getLogin().toLowerCase(), serverThread);

    return true;
  }