loolwsd/LOOLWSD.cpp | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-)
New commits: commit c8ea8bcacd1bc7503cb86a044d0bf320f0d45355 Author: Miklos Vajna <[email protected]> Date: Mon Jan 18 16:54:22 2016 +0100 loolwsd: handle WS messages split into multiple frames diff --git a/loolwsd/LOOLWSD.cpp b/loolwsd/LOOLWSD.cpp index d71e39c..78fcc7c 100644 --- a/loolwsd/LOOLWSD.cpp +++ b/loolwsd/LOOLWSD.cpp @@ -236,7 +236,25 @@ void SocketProcessor(std::shared_ptr<WebSocket> ws, break; } - if (firstLine.size() == static_cast<std::string::size_type>(n)) + if ((flags & WebSocket::FrameFlags::FRAME_FLAG_FIN) != WebSocket::FrameFlags::FRAME_FLAG_FIN) + { + // One WS message split into multiple frames. + std::vector<char> message(buffer, buffer + n); + while (true) + { + n = ws->receiveFrame(buffer, sizeof(buffer), flags); + message.insert(message.end(), buffer, buffer + n); + if ((flags & WebSocket::FrameFlags::FRAME_FLAG_FIN) == WebSocket::FrameFlags::FRAME_FLAG_FIN) + { + // No more frames: invoke the handler. Assume + // for now that this is always a multi-line + // message. + handler(message.data(), message.size(), false); + break; + } + } + } + else if (firstLine.size() == static_cast<std::string::size_type>(n)) { handler(firstLine.c_str(), firstLine.size(), true); } _______________________________________________ Libreoffice-commits mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
