示例#1
0
文件: Server.java 项目: Pitel/dZama
  /**
   * 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;
  }
示例#2
0
文件: Server.java 项目: Pitel/dZama
 /**
  * Odesle informaci ostatnim hracum, ze je tento hrac uz neni ve hre
  *
  * @param login Login hrace
  */
 public synchronized void userOutGame(String login) {
   Enumeration<ServerThread> e = getClients().elements();
   while (e.hasMoreElements()) {
     ServerThread serverThread = e.nextElement();
     if (!serverThread.getLogin().toLowerCase().equals(login.toLowerCase())) {
       serverThread.userOutGame(login);
     }
   }
 }
示例#3
0
文件: Server.java 项目: Pitel/dZama
 /**
  * Provede odhlaseni uzivatele Odesle informaci o odhlaseni ostatnim uzivatelum
  *
  * @param serverThread Vlakno serveru
  */
 public synchronized void logout(ServerThread serverThread) {
   if (serverThread.getLogin() != null) {
     clients.remove(serverThread.getLogin().toLowerCase());
     Enumeration<ServerThread> e = getClients().elements();
     while (e.hasMoreElements()) {
       e.nextElement().userLogout(serverThread.getLogin());
     }
   }
 }