422dfd1767
Add a new program, loadtest, that runs a requested number of client sessions in parallel to a loolwsd server. A client session loads one of a list of test documents, and does some operations on it. Move the getTokenInteger() and getTokenString() functions out from LOOLSession into a new namespace LOOLProtocol, as they are neeeded also in the loadtest program. Add, also in LOOLProtocol, functions to parse some of the messages from the server. (In general that is done in client JavaScript code, of course; only for testing purposes needed in C++ code.)
70 lines
2 KiB
C++
70 lines
2 KiB
C++
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
|
/*
|
|
* 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_LOOLPROTOCOL_HPP
|
|
#define INCLUDED_LOOLPROTOCOL_HPP
|
|
|
|
#define LOK_USE_UNSTABLE_API
|
|
#include <LibreOfficeKit/LibreOfficeKitEnums.h>
|
|
|
|
namespace LOOLProtocol
|
|
{
|
|
// The frames sent from the client to the server are called
|
|
// "commands" and those sent from the server to the client are
|
|
// called "messages". At least until I come up with a better
|
|
// terminology.
|
|
|
|
// I don't want to call the latter "responses"
|
|
// because they are not necessarily responses to some "request" or
|
|
// "command". Also "event" would be misleading because that is
|
|
// typically used for things originated by the user, like key or
|
|
// mouse events. And in fact, those are here part of the
|
|
// "commands".
|
|
|
|
// Not sure if these enums will be needed
|
|
enum class Command
|
|
{
|
|
KEY,
|
|
LOAD,
|
|
MOUSE,
|
|
RESETSELECTION,
|
|
SAVEAS,
|
|
SELECTGRAPHIC,
|
|
SELECTTEXT,
|
|
STATUS,
|
|
TILE,
|
|
UNO,
|
|
};
|
|
|
|
enum class Message
|
|
{
|
|
CHILD,
|
|
CURSOR_VISIBLE,
|
|
ERROR,
|
|
GRAPHIC_SELECTION,
|
|
HYPERLINK_CLICKED,
|
|
INVALIDATE_CURSOR,
|
|
INVALIDATE_TILES,
|
|
STATUS,
|
|
TEXT_SELECTION,
|
|
TEXT_SELECTION_END,
|
|
TEXT_SELECTION_START,
|
|
TILE,
|
|
};
|
|
|
|
bool getTokenInteger(const std::string& token, const std::string& name, int& value);
|
|
bool getTokenString(const std::string& token, const std::string& name, std::string& value);
|
|
|
|
// Functions that parse messages. All return false if parsing fails
|
|
bool parseStatus(const std::string& message, LibreOfficeKitDocumentType& type, int& nParts, int& currentPart, int& width, int& height);
|
|
};
|
|
|
|
#endif
|
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|