#include <evo/ioasync_server.h>
template<class T = AsyncBuffers>
class evo::AsyncServerReplyT< T >
Handles sending server replies, and accounts for potentially out of order responses.
- This writes directly to the socket when possible – out of order responses are queued to maintain correct response order
- This is used by AsyncServerHandler, the base class for handlers used with AsyncServer
|
struct | Writer |
| Response writer used to group multiple writes together for best performance. More...
|
|
◆ OutBuffer
◆ This
◆ WriterFlags
Flags used with Writer.
Enumerator |
---|
wfNONE | |
wfDEFERRED | Deferred but not the last part of this response.
|
wfDEFERRED_LAST | Deferred and the last part of this response.
|
◆ AsyncServerReplyT()
Constructor.
- Parameters
-
bufs | Buffer to use for writes |
◆ deferred_active()
ulong deferred_active |
( |
| ) |
const |
|
inline |
Get current number of deferred responses in progress.
- Returns
- Number of current deferred responses in progress, 0 for none
◆ deferred_end()
bool deferred_end |
( |
U & |
context | ) |
|
|
inline |
Call when deferred response is finished.
- This is used to track the current number of deferred events are being waited on
- Call this only after response is fully sent with send()
- This calls send_end()
- Parameters
-
context | DeferredContext for current connection |
- Returns
- Whether this was the last context reference, meaning context was destroyed, false if not destroyed
◆ deferred_send()
This& deferred_send |
( |
ulong |
id, |
|
|
String & |
data, |
|
|
bool |
last |
|
) |
| |
|
inline |
Send deferred response for given request ID.
- Call gen_id() before response is deferred to get an ID to use
- Do not call this with non-deferred response, use send() instead
- Multiple calls with the same ID are effectively appended together, but must set
last=true
on last part of response
- Caution: Results are undefined if
last
isn't set correctly
- Parameters
-
id | Request ID for response |
data | Response data to send |
last | Whether this is the last part of the response, true to allow processing of next request response |
- Returns
- This
◆ deferred_start()
void deferred_start |
( |
U & |
context | ) |
|
|
inline |
Call when deferred response is started.
- This is used to track the current number of deferred events are being waited on
- Parameters
-
context | DeferredContext for current connection |
- Returns
- Whether this was the last context reference, meaning context was destroyed, false if not destroyed
◆ gen_id()
Generate a new request ID.
- Returns
- New request ID
◆ nosend()
Cancel current ID since current request doesn't have a response.
- This must be called before the next ID is created (i.e. before next request is processed), otherwise the connection will likely hang
- Parameters
-
◆ send()
void send |
( |
ulong |
id, |
|
|
String & |
data |
|
) |
| |
|
inline |
Send response for given request ID.
- Call gen_id() to get an ID to use
- Do not call this with deferred response, use deferred_send() instead
- Multiple calls with the same ID are effectively appended together
- Responses sent out of order are queued so they're actually sent in the right order
- Parameters
-
id | Request ID for response |
data | Response data to send |
◆ send_end()
End current response.
- Call after last send() for current response
- Not needed for deferred responses, deferred_end() calls this
The documentation for this class was generated from the following file: