offbynull / portmapper

Java library that maps ports on NAT-enabled routers (supported protocols: UPnP-IGD/NAT-PMP/PCP).
Apache License 2.0
88 stars 17 forks source link

The readme.md example might be wrong #42

Closed lpetrovic05 closed 5 years ago

lpetrovic05 commented 5 years ago

The snippet below has been taken from the readme.md file. The comment says that a mapping should be refreshed every 20 seconds and it should be set to last 40 seconds. So if the lifetime is 40 seconds, the this code refreshes every 40 seconds Thread.sleep(mappedPort.getLifetime() * 1000L) and sets its lifetime to half of that mappedPort.getLifetime() / 2L

// Refresh mapping half-way through the lifetime of the mapping (for example,
// if the mapping is available for 40 seconds, refresh it every 20 seconds)
while(!shutdown) {
    mappedPort = mapper.refreshPort(mappedPort, mappedPort.getLifetime() / 2L);
    System.out.println("Port mapping refreshed: " + mappedPort);
    Thread.sleep(mappedPort.getLifetime() * 1000L);
}
offbynull commented 5 years ago

Hi,

I think you're correct. You're more than welcome to submit a PR with the change. If not I'll get around to fixing it eventually.

Thanks!

lpetrovic05 commented 5 years ago

Hi, I created a pull request. Review and approve whenever convenient. Thanks