mirror of https://github.com/deavmi/doap
CoapClient
- Added `setExchangeLifetime(Duration)` CoapClient (unittests) - Manually set the exchange lifetime
This commit is contained in:
parent
f878136746
commit
c2075dd604
|
@ -104,6 +104,19 @@ public class CoapClient
|
|||
*/
|
||||
private Duration EXCHANGE_LIFETIME = dur!("msecs")(180);
|
||||
|
||||
/**
|
||||
* Sets the exchange lifetime. In other words
|
||||
* the duration of time that must pass before
|
||||
* a message ID is considered free-for-use again
|
||||
*
|
||||
* Params:
|
||||
* lifetime = the lifetime duration
|
||||
*/
|
||||
public void setExchangeLifetime(Duration lifetime)
|
||||
{
|
||||
this.EXCHANGE_LIFETIME = lifetime;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates a new message ID
|
||||
*
|
||||
|
@ -381,7 +394,15 @@ version(unittest)
|
|||
/**
|
||||
* Client testing
|
||||
*
|
||||
* Tests the rolling of the message id
|
||||
* Tests the rolling of the message id,
|
||||
* here I configure the `EXCHANGE_LIFETIME`
|
||||
* to be a value high enough to not have
|
||||
* them quickly expire.
|
||||
*
|
||||
* NOTE: In the future it may be calculated
|
||||
* in relation to other variables and we may
|
||||
* need a private method accessible here that
|
||||
* can override it
|
||||
*/
|
||||
unittest
|
||||
{
|
||||
|
@ -394,6 +415,8 @@ unittest
|
|||
.post();
|
||||
|
||||
|
||||
client.setExchangeLifetime(dur!("msecs")(180));
|
||||
|
||||
writeln("Future start (first)");
|
||||
CoapPacket response = future.get();
|
||||
writeln("Future done (first)");
|
||||
|
|
Loading…
Reference in New Issue