net/WebSocketHandler.hpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)
New commits: commit 0dab4b597da5dd6531eaa8634dbafe69a8b41a40 Author: Ashod Nakashian <[email protected]> Date: Sun Apr 9 18:24:51 2017 -0400 wsd: return the actual number of bytes written to WS Change-Id: Ib28c432927733ffd437d27dec749d402d25b9024 Reviewed-on: https://gerrit.libreoffice.org/36323 Reviewed-by: Ashod Nakashian <[email protected]> Tested-by: Ashod Nakashian <[email protected]> diff --git a/net/WebSocketHandler.hpp b/net/WebSocketHandler.hpp index 7c004c7c..85cad811 100644 --- a/net/WebSocketHandler.hpp +++ b/net/WebSocketHandler.hpp @@ -195,11 +195,14 @@ public: } else _wsPayload.insert(_wsPayload.end(), data, data + payloadLen); + assert(_wsPayload.size() >= payloadLen); + socket->_inBuffer.erase(socket->_inBuffer.begin(), socket->_inBuffer.begin() + headerLen + payloadLen); // FIXME: fin, aggregating payloads into _wsPayload etc. LOG_TRC("#" << socket->getFD() << ": Incoming WebSocket message code " << code << - " fin? " << fin << ", mask? " << hasMask << " payload length: " << _wsPayload.size()); + ", fin? " << fin << ", mask? " << hasMask << ", payload length: " << _wsPayload.size() << + ", residual socket data: " << socket->_inBuffer.size() << " bytes."); switch (code) { @@ -340,6 +343,7 @@ protected: socket->assertCorrectThread(); std::vector<char>& out = socket->_outBuffer; + const size_t oldSize = out.size(); out.push_back(flags); @@ -368,12 +372,12 @@ protected: // Copy the data. out.insert(out.end(), data, data + len); + const size_t size = out.size() - oldSize; if (flush) socket->writeOutgoingData(); - // Data + header. - return len + 2; + return size; } /// To be overriden to handle the websocket messages the way you need. _______________________________________________ Libreoffice-commits mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
