loolwsd: unload child view when client disconnects

Using a new internal command, when a client disconnects
an internal 'disconnect' message is dispatched so
the child process cleans up the ChildSession in question.

Change-Id: I34166ad59e84ae389a3913bd2430fe537225bb4b
Reviewed-on: https://gerrit.libreoffice.org/29650
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
This commit is contained in:
Ashod Nakashian 2016-10-09 16:37:13 -04:00 committed by Ashod Nakashian
parent 1edd37ea2d
commit 4fa7e53eae
3 changed files with 29 additions and 0 deletions

View file

@ -441,6 +441,10 @@ size_t DocumentBroker::removeSession(const std::string& id)
if (it != _sessions.end())
{
_sessions.erase(it);
// Let the child know the client has disconnected.
const std::string msg("child-" + id + " disconnect");
_childProcess->getWebSocket()->sendFrame(msg.data(), msg.size());
}
return _sessions.size();

View file

@ -1264,6 +1264,13 @@ private:
const auto it = _connections.find(viewId);
if (it != _connections.end())
{
if (message == "disconnect")
{
Log::debug("Removing ChildSession " + value);
_connections.erase(it);
return true;
}
auto session = it->second->getSession();
if (session)
{

View file

@ -373,6 +373,24 @@ saveas: url=<url>
<url> is a URL of the destination, encoded. Sent from the child to the
parent after a saveAs() completed.
client-<sessionId> <Payload Message>
Forwarding message between a child and its parent session.
The payload message is forwarded to the ClientSession.
parent -> child
===============
child-<sessionId> <Payload Message>
Forwarding message between a parent and its child session.
The payload message is forwarded to the ChildSession.
disconnect
Signals to the child that the client for the respective connection
has disconnected.
Admin console
===============