Package server.commands.methods

Source Code of server.commands.methods.CheckForNameInUse

package server.commands.methods;

import java.util.Iterator;

import org.quickserver.net.server.ClientHandler;

import server.protocol.ClientInfo;
import server.protocol.GameRoom;

/**
* The Class CheckForNameInUse. Handles the name-checking.
*/
public class CheckForNameInUse {
 
  private ClientInfo data;
 
  /**
   * Check for name in use.
   *
   * @param name the name that will be checked
   * @param room the room that will be checked
   * @return true, if successful
   */
  public boolean checkForNameInUse(String name, GameRoom room) {
    Iterator<ClientHandler> iterator = room.getClients().iterator();
    ClientHandler toHandler = null;
    while (iterator.hasNext()) {
      toHandler = (ClientHandler) iterator.next();
      data = (ClientInfo) toHandler.getClientData();
      if (name.equals(data.getName()))
        return true;
    }
    return false;
  }
}
TOP

Related Classes of server.commands.methods.CheckForNameInUse

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.