mirror of https://github.com/deavmi/tasky.git
Compare commits
4 Commits
93d6d49c20
...
a51df3b699
Author | SHA1 | Date |
---|---|---|
Tristan B. Velloza Kildaire | a51df3b699 | |
Tristan B. Velloza Kildaire | 8387d0ee78 | |
Tristan B. Velloza Kildaire | 7af21a909a | |
Tristan B. Velloza Kildaire | 7072c852dc |
|
@ -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);
|
||||
|
|
|
@ -7,8 +7,6 @@ public alias ResponseHandler = void function(byte[]);
|
|||
public abstract class Request
|
||||
{
|
||||
private byte[] requestMessage;
|
||||
|
||||
// TODO: Define the below with an alias for a function pointer that accepts a byte[] (the response data)
|
||||
|
||||
private ResponseHandler respFunc;
|
||||
|
||||
|
@ -18,6 +16,11 @@ public abstract class Request
|
|||
this.respFunc = respFunc;
|
||||
}
|
||||
|
||||
protected this(byte[] requestMessage)
|
||||
{
|
||||
this(requestMessage, null);
|
||||
}
|
||||
|
||||
package final byte[] getRequestData()
|
||||
{
|
||||
return requestMessage;
|
||||
|
@ -27,4 +30,9 @@ public abstract class Request
|
|||
{
|
||||
respFunc(responseData);
|
||||
}
|
||||
|
||||
package final bool expectsResponse()
|
||||
{
|
||||
return respFunc !is null;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue