diff --git a/common/MessageQueue.cpp b/common/MessageQueue.cpp index b32fdebde..12a2abbe7 100644 --- a/common/MessageQueue.cpp +++ b/common/MessageQueue.cpp @@ -152,7 +152,7 @@ void TileQueue::put_impl(const Payload& value) void TileQueue::removeDuplicate(const std::string& tileMsg) { - assert(LOOLProtocol::getFirstToken(tileMsg) == "tile"); + assert(LOOLProtocol::matchPrefix("tile", tileMsg, /*ignoreWhitespace*/ true)); // Ver is always provided at this point and it is necessary to // return back to clients the last rendered version of a tile @@ -200,7 +200,7 @@ void TileQueue::deprioritizePreviews() // stop at the first non-tile or non-'id' (preview) message std::string id; - if (LOOLProtocol::getFirstToken(message) != "tile" || + if (!LOOLProtocol::matchPrefix("tile", message) || !LOOLProtocol::getTokenStringFromMessage(message, "id", id)) { break; @@ -218,7 +218,7 @@ MessageQueue::Payload TileQueue::get_impl() auto msg = std::string(front.data(), front.size()); std::string id; - bool isTile = (LOOLProtocol::getFirstToken(msg) == "tile"); + bool isTile = LOOLProtocol::matchPrefix("tile", msg); bool isPreview = isTile && LOOLProtocol::getTokenStringFromMessage(msg, "id", id); if (!isTile || isPreview) { @@ -246,7 +246,7 @@ MessageQueue::Payload TileQueue::get_impl() // avoid starving - stop the search when we reach a non-tile, // otherwise we may keep growing the queue of unhandled stuff (both // tiles and non-tiles) - if (LOOLProtocol::getFirstToken(prio) != "tile" || + if (!LOOLProtocol::matchPrefix("tile", prio) || LOOLProtocol::getTokenStringFromMessage(prio, "id", id)) { break; @@ -277,7 +277,7 @@ MessageQueue::Payload TileQueue::get_impl() { auto& it = _queue[i]; msg = std::string(it.data(), it.size()); - if (LOOLProtocol::getFirstToken(msg) != "tile" || + if (!LOOLProtocol::matchPrefix("tile", msg) || LOOLProtocol::getTokenStringFromMessage(msg, "id", id)) { // Don't combine non-tiles or tiles with id. diff --git a/test/helpers.hpp b/test/helpers.hpp index a10cc5354..b33dcb497 100644 --- a/test/helpers.hpp +++ b/test/helpers.hpp @@ -324,7 +324,7 @@ bool isDocumentLoaded(LOOLWebSocket& ws, const std::string& name = "", bool isVi { const std::string prefix = isView ? "status:" : "statusindicatorfinish:"; const auto message = getResponseString(ws, prefix, name); - return LOOLProtocol::getFirstToken(message) == prefix; + return LOOLProtocol::matchPrefix(prefix, message); } inline