mirror of
https://github.com/deavmi/doap
synced 2024-07-04 14:30:55 +02:00
CoapRequest
- Now takes in the original request packet, `CoapPacket` instead of the token - Added `getToken()` to fetch the token (for matching purposes) - Added `getRequestPacket()` to obtain the original request CoapClient - Use `getToken()` - Pass the `CoapPacket` in rather
This commit is contained in:
parent
497dabf6bf
commit
2716fd3986
|
@ -151,7 +151,7 @@ public class CoapClient
|
||||||
CoapRequestFuture future = new CoapRequestFuture();
|
CoapRequestFuture future = new CoapRequestFuture();
|
||||||
|
|
||||||
// Link the CoapRequest to the future so it can be signalled
|
// Link the CoapRequest to the future so it can be signalled
|
||||||
CoapRequest request = new CoapRequest(requestPacket.getToken(), future);
|
CoapRequest request = new CoapRequest(requestPacket, future);
|
||||||
|
|
||||||
// Store the request
|
// Store the request
|
||||||
storeRequest(request);
|
storeRequest(request);
|
||||||
|
@ -194,7 +194,7 @@ public class CoapClient
|
||||||
|
|
||||||
foreach(CoapRequest request; outgoingRequests)
|
foreach(CoapRequest request; outgoingRequests)
|
||||||
{
|
{
|
||||||
if(request.token == token)
|
if(request.getToken() == token)
|
||||||
{
|
{
|
||||||
foundRequest = request;
|
foundRequest = request;
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -21,10 +21,10 @@ import doap.exceptions;
|
||||||
package class CoapRequest
|
package class CoapRequest
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* The token to be able to match a response
|
* The original packet (to be able to access the token
|
||||||
* to
|
* such that we can match it up with a respnse)
|
||||||
*/
|
*/
|
||||||
package ubyte[] token;
|
private CoapPacket requestPacket;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The future which we can fill up with the
|
* The future which we can fill up with the
|
||||||
|
@ -36,15 +36,25 @@ package class CoapRequest
|
||||||
* Constructs a new request
|
* Constructs a new request
|
||||||
*
|
*
|
||||||
* Params:
|
* Params:
|
||||||
* token = the token
|
* requestPacket = the actual request
|
||||||
* future = the `CoapRequestFuture` to wake up
|
* future = the `CoapRequestFuture` to wake up
|
||||||
* on data arrival
|
* on data arrival
|
||||||
*/
|
*/
|
||||||
this(ubyte[] token, CoapRequestFuture future)
|
this(CoapPacket requestPacket, CoapRequestFuture future)
|
||||||
{
|
{
|
||||||
this.token = token;
|
this.requestPacket = requestPacket;
|
||||||
this.future = future;
|
this.future = future;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public CoapPacket getRequestPacket()
|
||||||
|
{
|
||||||
|
return this.requestPacket;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ubyte[] getToken()
|
||||||
|
{
|
||||||
|
return this.requestPacket.getToken();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue
Block a user