- If a `Request` is not expecting a response then do not call `dequeue()` on the `Queue` registered nor `process`byte[])`
- Added a TODO comment
This commit is contained in:
Tristan B. Velloza Kildaire 2023-05-04 14:17:35 +02:00
parent 8387d0ee78
commit a51df3b699
1 changed files with 11 additions and 4 deletions

View File

@ -14,6 +14,8 @@ public class Engine
// TODO: Continue working on this
// TODO: Allow registering ResponseAnonymous with handlers etc
/**
* Takes a request and sends it through to the endpoint
* afterwhich we block for a response and when we get one
@ -35,11 +37,16 @@ public class Engine
/* Send the message */
tManager.sendMessage(tReq);
/* Await for a response */
byte[] resp = newQueue.dequeue().getPayload();
/* Does this Request expect a response? */
// TODO: We need not register the queue even if this is the case
if(req.expectsResponse())
{
/* Await for a response */
byte[] resp = newQueue.dequeue().getPayload();
/* Run the response handler with the response */
req.process(resp);
/* Run the response handler with the response */
req.process(resp);
}
/* De-register the queue */
tManager.releaseQueue(newQueue);