Ejemplo n.º 1
0
 public void submitRunnable(Runnable r) {
   try {
     server.submitRunnable(r);
   } catch (SimonRemoteException e) {
     e.printStackTrace();
     eventbus.publish(new TimEvent(Tag.INFO, "Cannot send runnable"));
   }
 }
Ejemplo n.º 2
0
  @Override
  public void onEvent(TimEvent evt) {

    switch (evt.getTag()) {
      case SENDFILE:
        Image img = this.getFile((String) evt.getObject());
        System.out.println("Image downloaded: " + img);
        // FIXME easy and dumm check for nullpointerException
        if (img != null) {
          showPreviewOfPicture(img);
        }
        break;

      case SENDRUNNER:
        try {
          Lookup lookup = Simon.createNameLookup(SERVER_HOST, REG_PORT);
          ITimRunner runner = (ITimRunner) lookup.lookup("TimRunner");
          server.submitRunnable(runner);
        } catch (Exception e) {
          e.printStackTrace();
        }
        break;

      case FILELIST:
        String[] filelist = server.listFiles();
        eventbus.publish(new TimEvent(Tag.GUIFILELIST, filelist));
        break;

      case INFO:
        System.out.println("Client received INFO-TAG!\n" + evt.getObject());
        break;

      case CLIENT_SHUTDOWN:
        this.shutdown();

      default:
        System.out.println("Client received unknown Tag on Event-Bus!");
    }
  }