(server) attempt at fixing #131 by using blocking writes in server mode

This commit is contained in:
Benjamin Sergeant
2019-12-12 12:17:29 -08:00
parent e223f8fac2
commit cae016564e
4 changed files with 48 additions and 18 deletions

View File

@ -61,7 +61,8 @@ namespace ix
enum class PollResult
{
Succeeded,
AbnormalClose
AbnormalClose,
CannotFlushSendBuffer
};
using OnMessageCallback =
@ -135,6 +136,10 @@ namespace ix
// client should mask but server should not
std::atomic<bool> _useMask;
// Tells whether we should flush the send buffer before
// saying that a send is complete. This is the mode for server code.
std::atomic<bool> _blockingSend;
// Buffer for reading from our socket. That buffer is never resized.
std::vector<uint8_t> _readbuf;
@ -238,6 +243,7 @@ namespace ix
size_t closeWireSize,
bool remote);
bool flushSendBuffer();
void sendOnSocket();
WebSocketSendInfo sendData(wsheader_type::opcode_type type,
const std::string& message,