public IStatus execute(
      IProgressMonitor monitor,
      ICommand command,
      IReturnValueConsumer returnValueConsumer,
      Options options) {
    monitor.beginTask(null, 100);

    monitor.subTask(Messages.DNSSDRemoteCommandService_ResolveRemoteCommandService);

    boolean doResolve = false;
    synchronized (info) {
      if (!resolving) {
        resolving = true;
        doResolve = true;
      }
    }

    DNSSDService resolver = null;
    if (doResolve) {
      try {
        resolver = DNSSD.resolve(flags, ifIndex, serviceName, regType, domain, this);
      } catch (DNSSDException e) {
        return new Status(
            IStatus.ERROR,
            LANRemoteCommandPlugin.ID,
            Messages.DNSSDRemoteCommandService_FailedResolveRemoteCommand,
            e);
      }
    }
    try {
      while (resolving) {
        if (monitor.isCanceled()) return Status.CANCEL_STATUS;
        Thread.sleep(0);
      }
    } catch (InterruptedException e) {
      return Status.CANCEL_STATUS;
    } finally {
      if (resolver != null) {
        resolver.stop();
      }
    }

    if (monitor.isCanceled()) return Status.CANCEL_STATUS;
    monitor.worked(10);

    monitor.subTask(Messages.DNSSDRemoteCommandService_SendCommand);
    IProgressMonitor handleMonitor = new SubProgressMonitor(monitor, 90);
    OutgoingSocketCommandHandler handler = new OutgoingSocketCommandHandler(info.getAddress());
    handler.setPluginId(LANRemoteCommandPlugin.ID);
    handler.setSocketPool(socketPool);
    IStatus handled =
        handler.handleOutgoingCommand(
            handleMonitor, command, returnValueConsumer, options.timeout());
    if (!handleMonitor.isCanceled()) handleMonitor.done();
    return handled;
  }
 public void start() {
   logger.info("Registration Starting");
   logger.info("Requested Name: " + name);
   logger.info("          Port: " + port);
   try {
     dnss = DNSSD.register(name, service, port, this);
   } catch (DNSSDException e) {
     logger.error("Could not register ZeroConfig service", e);
   }
 }
Esempio n. 3
0
  public Register(String name, int port) throws DNSSDException, InterruptedException {

    Synchronisateur sy = new Synchronisateur();

    if (sy.synchronisation(4150)) {

      System.out.println("Registration Starting");
      System.out.println("Requested Name: " + name);
      System.out.println("          Port: " + port);

      DNSSDRegistration r =
          DNSSD.register(name, "_ebsf_socket._udp", port, (RegisterListener) this);

      Thread.sleep(60000); // Wait thirty seconds, then exit
      System.out.println("Registration Stopping");
      r.stop();
    }
  }