/** @param args the command line arguments */
 public static void main(String[] args) throws Exception {
   try {
     conf = new JsonFile("config.json").read();
     address = conf.getJson().get("bind_IP").toString();
     port = Integer.parseInt(conf.getJson().get("port").toString());
     collection = new CollectThread(conf);
     collection.start();
     s = new ServerSocket(port, 50, InetAddress.getByName(address));
     System.out.print("(" + new GregorianCalendar().getTime() + ") -> ");
     System.out.print("listening on: " + address + ":" + port + "\n");
   } catch (Exception e) {
     System.out.print("(" + new GregorianCalendar().getTime() + ") -> ");
     System.out.print("error: " + e);
   }
   while (true) {
     try {
       sock = s.accept();
       System.out.print("(" + new GregorianCalendar().getTime() + ") -> ");
       System.out.print("connection from " + sock.getInetAddress() + ":");
       System.out.print(sock.getPort() + "\n");
       server = new ConsoleThread(conf, sock);
       server.start();
     } catch (Exception e) {
       System.out.print("(" + new GregorianCalendar().getTime() + ") -> ");
       System.out.print("error: " + e);
       continue;
     }
   }
 }
Ejemplo n.º 2
0
  /**
   * This starts the layout thread, it does not run before this. Note this is a background check it
   * doesn't stop when done it just sleeps until it gets more work.
   */
  public void start() {

    if (controller != null && !runner.isAlive() && !pauseState) {
      active = true;
      runner.start();
    }
  }
Ejemplo n.º 3
0
  /** Creates a thread and runs a test case */
  public void runTest() {
    // anonymous inner class for thread target
    Thread myThread =
        new Thread(
            this.myGroup,
            new Runnable() {
              public void run() {
                while (!RunLoadTest.isOutOfTime()) {
                  doTest();
                  try {
                    Thread.sleep(500);
                  } catch (InterruptedException e) {
                    System.out.println(e.getMessage());
                  }
                }
                System.out.println("Test " + myGroup + " Stopped! ==> " + reqCount + " Runs.");
              }
            });

    myThread.start();
  }
Ejemplo n.º 4
0
  // MTProto
  public MTProto(int dc_id, MTProtoListener callback, int reuseFlag) {
    this.reuseFlag = reuseFlag;
    cb = callback;
    for (int i = 0; i < dcStates.size(); i++)
      if (dcStates.get(i).getInt("id") == dc_id) {
        dcState = dcStates.get(i);
        // Common.hexStringToByteArray("23D03699CE2AB29BA2273084D95DA126EC3A1D55BE4C317615CE66609D5562BDC0EFDE5AE1F9185001C35781F622B31DF5294685559340DE7D5CC8D7F6F86AE049107D8E498EB2AC3D6FA735DF90648EEC34A6B7BE3A5075A455F5696DB39280BF68C1637E1580E1EBA3F0C12EF2C03B8E9B5ECCFD3E4885BF636863388E3EC9E9EF60C722FF9B45CD93FA5E8D0D277B45A6A9370860582A159187F2F352D418D195D8E9310B5559E170F51CB2056F6CB6DB586E9349192A1B7EAA50887C115A14F996F5A855E90E47635A81EA3048615F4FD91347D73335E5503179857D0D29132483271B28E6591172C3D94686BD96E91FDB7AD9591A526218B3DDFC7A2A09")
        setAuthKey(dcState.getBytes("auth_key"));
        bind = dcState.getBool("bind");
        seqno = dcState.getInt("seqno");
        session = dcState.getLong("session");
        server_salt = dcState.getLong("server_salt");
        Common.logError("session: " + session + " seqno: " + seqno);

        connected = false;
        Thread netThread = new Thread(transport = new TransportTCP(this, true));
        netThread.setPriority(Thread.MIN_PRIORITY);
        netThread.start();

        return;
      }
    Common.logError("dc not found: " + dc_id);
  }