mirror of
https://github.com/deavmi/doap
synced 2024-07-04 15:50:15 +02:00
CoapRequest
- Removed `getAndReset()`, replaced it with `hasTimedOut(Duration)` CoapClient - The `watch()` now uses `CoapRequest`'s new `hasTimedOut(Duration)` method
This commit is contained in:
parent
31b5d13943
commit
ed97a2a3b4
|
@ -253,7 +253,7 @@ public class CoapClient
|
|||
requestsLock.lock();
|
||||
foreach(CoapRequest curReq; outgoingRequests)
|
||||
{
|
||||
if(curReq.getAndReset() >= retransmitTimeout)
|
||||
if(curReq.hasTimedOut(retransmitTimeout))
|
||||
{
|
||||
// TODO: Retransmit
|
||||
}
|
||||
|
|
|
@ -73,17 +73,28 @@ package class CoapRequest
|
|||
}
|
||||
|
||||
/**
|
||||
* Gets the current elapsed time and
|
||||
* then resets it
|
||||
* Checks if this request has expired
|
||||
* according to the given timeout
|
||||
* threshold
|
||||
*
|
||||
* Returns: the elapsed time
|
||||
* If timed out then the timer
|
||||
* restarts.
|
||||
*
|
||||
* Returns: `true` if timed out,
|
||||
* `false` if not
|
||||
*/
|
||||
package Duration getAndReset()
|
||||
package bool hasTimedOut(Duration timeoutThreshold)
|
||||
{
|
||||
// Check if the threshold has been reached
|
||||
if(timer.peek() >= timeoutThreshold)
|
||||
{
|
||||
// Get the value and restart timer
|
||||
Duration elapsed = timer.peek();
|
||||
timer.reset();
|
||||
return elapsed;
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user