2017-07-03 09:30:10 +02:00
|
|
|
/*!
|
|
|
|
* \brief Dispatch Messages of JSON API.
|
|
|
|
*
|
2018-03-28 15:10:51 +02:00
|
|
|
* \copyright Copyright (c) 2016-2018 Governikus GmbH & Co. KG, Germany
|
2017-07-03 09:30:10 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "context/AuthContext.h"
|
|
|
|
#include "context/WorkflowContext.h"
|
|
|
|
#include "messages/MsgContext.h"
|
|
|
|
#include "messages/MsgHandler.h"
|
|
|
|
|
|
|
|
#include <QJsonDocument>
|
|
|
|
#include <QString>
|
|
|
|
|
|
|
|
#include <functional>
|
|
|
|
|
|
|
|
namespace governikus
|
|
|
|
{
|
|
|
|
|
|
|
|
class MessageDispatcher
|
|
|
|
{
|
|
|
|
private:
|
|
|
|
MsgDispatcherContext mContext;
|
|
|
|
|
|
|
|
MsgHandler createForStateChange(MsgType pStateType);
|
|
|
|
MsgHandler createForCommand(const QJsonObject& pObj);
|
|
|
|
|
|
|
|
MsgHandler cancel();
|
|
|
|
MsgHandler accept();
|
|
|
|
MsgHandler handleCurrentState(MsgCmdType pCmdType, MsgType pMsgType, const std::function<MsgHandler()>& pFunc);
|
|
|
|
|
|
|
|
public:
|
|
|
|
MessageDispatcher();
|
|
|
|
|
|
|
|
QByteArray init(const QSharedPointer<WorkflowContext>& pContext);
|
|
|
|
QByteArray finish();
|
|
|
|
QByteArray processCommand(const QByteArray& pMsg);
|
|
|
|
QByteArray processStateChange(const QString& pState);
|
|
|
|
|
|
|
|
QByteArray createMsgReader(const QString& pName) const;
|
|
|
|
};
|
|
|
|
|
|
|
|
} /* namespace governikus */
|