public void initialize() {
    // Register rate ticker event
    System.out.print("Registering listeners...");

    // Register pair watcher event
    this.pw = new PairWatch(this.pairName);
    try {
      fxclient.getRateTable().getEventManager().add(this.pw);
    } catch (SessionException e) {
      System.out.println("Error in Ticker:2");
    }
  }
Exemple #2
0
  public static void main(String[] args) {
    if (args.length != 2) {
      System.out.println("Usage: Transfeed [username] [password]");
      System.exit(1);
    }

    // Connect to FXServer
    FXClient fxclient = API.createFXGame();
    fxclient.setWithKeepAliveThread(true);
    System.out.print("Logging in as \"" + args[0] + "\"...");
    try {
      fxclient.login(args[0], args[1], "TransFeed Test");
    } catch (SessionException e) {
      System.exit(1);
    } catch (InvalidUserException e) {
      System.exit(1);
    } catch (InvalidPasswordException e) {
      System.exit(1);
    } catch (MultiFactorAuthenticationException e) {
      System.exit(1);
    }

    // Register transaction feed event
    System.out.print("login complete. Registering listener...");
    TFEvent evt = new TFEvent();
    try {
      ((Account) fxclient.getUser().getAccounts().elementAt(0)).getEventManager().add(evt);
    } catch (AccountException err) {
      fxclient.logout();
      System.exit(1);
    } catch (SessionException err) {
      fxclient.logout();
      System.exit(1);
    }

    // Sleep for a minute, let it run
    System.out.println("done. Listening for transactions for one day...");
    try {
      Thread.sleep(60000 * 60 * 24);
    } catch (InterruptedException e) {
    } // Interrupted, just keep running

    // Done, quit now
    System.out.println("One minute elapsed.  Logging out and exiting.");
    fxclient.logout();
  }