libreoffice-online/loolwsd/LOOLWSD.hpp
Ashod Nakashian bb16272e11 loolwsd: DocumentStoreManager -> DocumentBroker
Renamed DocumentStoreManager to DocumentBroker and
restructured the handshake process.

Currently, at first client connection to a given doc
a DocumentBroker is created to serve as the clearing house
of all client-side activities on the document.

Prime goals is loading and saving of the document, but
also to guarantee race-free management of the doc.

Each doc has a unique DocKey based on the URL (the path,
without queries). This DocKey is used as key into a map
of all DocumentBrokers. The latter is shared among
MasterProcessSession instances.

Change-Id: I569f2d235676e88ddc690147f3cb89faa60388c2
Reviewed-on: https://gerrit.libreoffice.org/23216
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-03-14 03:10:08 +00:00

79 lines
2.2 KiB
C++

/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#ifndef INCLUDED_LOOLWSD_HPP
#define INCLUDED_LOOLWSD_HPP
#include <atomic>
#include <mutex>
#include <string>
#include <Poco/Path.h>
#include <Poco/Process.h>
#include <Poco/Random.h>
#include <Poco/Util/OptionSet.h>
#include <Poco/Util/ServerApplication.h>
#include "Auth.hpp"
#include "Common.hpp"
#include "DocumentBroker.hpp"
#include "Util.hpp"
class MasterProcessSession;
class LOOLWSD: public Poco::Util::ServerApplication
{
public:
LOOLWSD();
~LOOLWSD();
// An Application is a singleton anyway,
// so just keep these as statics.
static std::atomic<unsigned> NextSessionId;
static int NumPreSpawnedChildren;
static int BrokerWritePipe;
static bool DoTest;
static std::string Cache;
static std::string SysTemplate;
static std::string LoTemplate;
static std::string ChildRoot;
static std::string LoSubPath;
//static Auth AuthAgent;
static const std::string PIDLOG;
static const std::string FIFO_PATH;
static const std::string FIFO_LOOLWSD;
static const std::string LOKIT_PIDLOG;
// All DocumentBrokers by their DocKey (the URI path without host, port, or query).
static std::map<std::string, std::shared_ptr<DocumentBroker>> DocBrokers;
static std::mutex DocBrokersMutex;
static
std::string GenSessionId()
{
return Util::encodeId(++NextSessionId, 4);
}
protected:
void initialize(Poco::Util::Application& self) override;
void uninitialize() override;
void defineOptions(Poco::Util::OptionSet& options) override;
void handleOption(const std::string& name, const std::string& value) override;
int main(const std::vector<std::string>& args) override;
private:
void displayHelp();
void displayVersion();
Poco::Process::PID createBroker();
};
#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */