Never compress 0 bytes, finish pub/sub ded. compr.

This commit is contained in:
Alex Hultman
2020-06-22 07:10:43 +02:00
parent e9e6d3fa34
commit f52d816032
5 changed files with 21 additions and 10 deletions
+13 -4
View File
@@ -92,15 +92,22 @@ public:
WebSocket<SSL, true> *ws = (WebSocket<SSL, true> *) asyncSocket;
/* We need to handle being corked, and corking here */
bool needsUncorking = false;
if (!ws->isCorked() && ws->canCork()) {
asyncSocket->cork();
needsUncorking = true;
}
while (selectedData.length()) {
/* Interpret the data like so */
/* Interpret the data like so, because this is how we shoved it in */
MessageMetadata mm;
memcpy((char *) &mm, selectedData.data(), sizeof(MessageMetadata));
std::string_view unframedMessage(selectedData.data() + sizeof(MessageMetadata), mm.length);
//std::cout << "<" << unframedMessage << ">" << std::endl;
/* Skip this message if our backpressure is too high */
if (maxBackpressure && ws->getBufferedAmount() > maxBackpressure) {
break;
}
/* Here we perform the actual compression and framing */
ws->send(unframedMessage, mm.opCode, mm.compress);
@@ -110,7 +117,9 @@ public:
}
/* Here we need to uncork or keep it as was */
if (needsUncorking) {
asyncSocket->uncork();
}
/* See below */
return 0;