[Libreoffice-commits] online.git: Branch 'distro/collabora/milestone-7' - loolwsd/LOOLWSD.cpp

Miklos Vajna vmiklos at collabora.co.uk
Mon Jan 18 08:21:47 PST 2016


 loolwsd/LOOLWSD.cpp |   18 +++++++++++++++++-
 1 file changed, 17 insertions(+), 1 deletion(-)

New commits:
commit 2f964e74a84903b13996ac4e31271f383bc1fcaf
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Mon Jan 18 16:54:22 2016 +0100

    loolwsd: handle WS messages split into multiple frames
    
    (cherry picked from commit c8ea8bcacd1bc7503cb86a044d0bf320f0d45355)
    
    Conflicts:
    	loolwsd/LOOLWSD.cpp
    
    Change-Id: I00199a95fa0a429d29923d0f64980608903227a1

diff --git a/loolwsd/LOOLWSD.cpp b/loolwsd/LOOLWSD.cpp
index 98092ae..f18d868 100644
--- a/loolwsd/LOOLWSD.cpp
+++ b/loolwsd/LOOLWSD.cpp
@@ -427,7 +427,23 @@ public:
                             std::string firstLine = getFirstLine(buffer, n);
                             StringTokenizer tokens(firstLine, " ", StringTokenizer::TOK_IGNORE_EMPTY | StringTokenizer::TOK_TRIM);
 
-                            if (kind == LOOLSession::Kind::ToClient && 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.
+                                        session->handleInput(message.data(), message.size());
+                                        break;
+                                    }
+                                }
+                            }
+                            else if (kind == LOOLSession::Kind::ToClient && firstLine.size() == static_cast<std::string::size_type>(n))
                             {
                                 queue.put(firstLine);
                             }


More information about the Libreoffice-commits mailing list