Exemple #1
0
 public boolean userIsBlocked(String username) {
   User user = this.getUser(username);
   if (user == null) {
     return false;
   } else {
     return user.isBlocked();
   }
 }
Exemple #2
0
  public static void main(String[] args) throws Exception {

    // Seteo los puertos en los que escucho nuevas conexiones.
    initPorts();

    // Seteo las configuraciones globales de los usuarios
    User.initGlobalConfiguration();

    // Tomar conf;
    try {
      PropertyConfigurator.configure("resources/log4j.properties");
    } catch (Exception e) {
      e.printStackTrace();
      System.out.println("Error loading logger");
      // return;
    }
    welcomeSocket = ServerSocketChannel.open();
    adminSocket = ServerSocketChannel.open();
    statsSocket = ServerSocketChannel.open();
    try {

      welcomeSocket.socket().bind(new InetSocketAddress(welcomeSocketPort));
      welcomeSocket.configureBlocking(true);

      clientsThread = new ClientWelcomeSocket(threadPool, welcomeSocket);

      adminSocket.socket().bind(new InetSocketAddress(adminPort));
      adminSocket.configureBlocking(false);

      statsSocket.socket().bind(new InetSocketAddress(statsPort));
      statsSocket.configureBlocking(false);

      adminsThread = new AdminWelcomeSocket(adminSocket);
      statsThread = new StatsWelcomeSocket(statsSocket);

      threadPool.execute(clientsThread);
      threadPool.execute(adminsThread);
      threadPool.execute(statsThread);
    } catch (NotYetBoundException nybe) {
      // TODO:
    } catch (IOException ioe) {
      // TODO:
    } catch (Exception e) {
      // TODO:
    }

    //		do {
    //			clientsThread.join(60000);
    //			adminsThread.join(60000);
    //		}while(clientsThread.isAlive() || adminsThread.isAlive());
  }