Exemplo n.º 1
0
  @Override
  public synchronized int addUpnpMapping(
      final PortMappingProtocol prot,
      final int localPort,
      final int externalPortRequested,
      final PortMapListener portMapListener) {

    if (NetworkUtils.isPublicAddress()) {
      // Return value is not used.
      return 1;
    }

    // This call will block unless we thread it here.
    final Runnable upnpRunner =
        new Runnable() {
          @Override
          public void run() {
            addMapping(prot, externalPortRequested, localPort, portMapListener);
          }
        };
    final Thread mapper = new Thread(upnpRunner, "UPnP-Mapping-Thread");
    mapper.setDaemon(true);
    mapper.start();

    // Return value is not used.
    return 1;
  }