20 WsjcppError(
int nCodeError,
const std::string &sMessage);
36 void fillFrom(nlohmann::json
const& obj);
44 void setNick(QString);
47 std::string userUuid();
77 void processTextMessage(
const QString &
message);
78 void processBinaryMessage(QByteArray
message);
79 void socketDisconnected();
88 virtual void sendMessage(QWebSocket *pClient,
const nlohmann::json& jsonResponse) = 0;
89 virtual void sendMessageError(QWebSocket *pClient,
const std::string &sCmd,
const std::string & sM,
WsjcppError error) = 0;
90 virtual void sendToAll(
const nlohmann::json& jsonMessage) = 0;
91 virtual void sendToOne(QWebSocket *pClient,
const nlohmann::json &jsonMessage) = 0;
92 virtual int getConnectedUsers() = 0;
93 virtual void setWsjcppUserSession(QWebSocket *pClient,
WsjcppUserSession *pUserSession) = 0;
103 CmdInputDef(
const std::string &sName,
const std::string &sDescription);
111 CmdInputDef & description(
const std::string &sDescription);
114 nlohmann::json toJson();
116 const std::string &getType();
117 const std::string &getType()
const;
118 const std::string &getName();
119 const std::string &getName()
const;
120 const std::string &getRestrict();
121 const std::string &getRestrict()
const;
122 const std::string &getDescription();
123 const std::string &getDescription()
const;
138 const std::vector<WsjcppValidatorStringBase *> &listOfValidators();
150 std::string CMD_INPUT_DEF_TYPE_INTEGER =
"integer";
151 std::string CMD_INPUT_DEF_TYPE_STRING =
"string";
152 std::string CMD_INPUT_DEF_TYPE_BOOL =
"boolean";
153 std::string CMD_INPUT_DEF_TYPE_ANY =
"any";
163 QWebSocket *client();
164 std::string getIpAddress();
169 bool isUnauthorized();
172 const nlohmann::json& jsonRequest();
173 bool hasInputParam(
const std::string &sParamName);
174 std::string getInputString(
const std::string &sParamName,
const std::string &sDefaultValue);
175 int getInputInteger(
const std::string &sParamName,
int defaultValue);
179 std::string command();
181 void sendMessageError(
const std::string &cmd,
WsjcppError error);
182 void sendMessageSuccess(
const std::string &cmd, nlohmann::json& jsonResponse);
183 void sendResponse(nlohmann::json& jsonResult);
205 CmdHandlerBase(
const std::string &sCmd,
const std::string &sDescription);
206 virtual std::string cmd();
207 virtual std::string description();
208 std::string activatedFromVersion();
209 std::string deprecatedFromVersion();
210 bool accessUnauthorized();
215 virtual const std::vector<CmdInputDef> &inputs();
222 void setAccessUnauthorized(
bool bAccess);
223 void setAccessUser(
bool bAccess);
224 void setAccessAdmin(
bool bAccess);
225 void setActivatedFromVersion(
const std::string &sActivatedFromVersion);
226 void setDeprecatedFromVersion(
const std::string &sDeprecatedFromVersion);
228 CmdInputDef &requireStringParam(
const std::string &sName,
const std::string &sDescription);
229 CmdInputDef &optionalStringParam(
const std::string &sName,
const std::string &sDescription);
230 CmdInputDef &requireIntegerParam(
const std::string &sName,
const std::string &sDescription);
231 CmdInputDef &optionalIntegerParam(
const std::string &sName,
const std::string &sDescription);
232 CmdInputDef &requireBooleanParam(
const std::string &sName,
const std::string &sDescription);
233 CmdInputDef &optionalBooleanParam(
const std::string &sName,
const std::string &sDescription);
259 static void initGlobalVariables();
260 static void addHandler(
const std::string &sName,
CmdHandlerBase* pCmdHandler);
265 #define REGISTRY_CMD( classname ) \ 266 static classname * pRegistry ## classname = new classname(); \ 281 #endif // CMD_HADNLERS_H
WsjcppUserSession * m_pUserSession
Definition: cmd_handlers.h:73
std::map< std::string, CmdHandlerBase * > * g_pCmdHandlers
Definition: cmd_handlers.cpp:807
This handler will be return list of handlers - publish api interfaces.
Definition: cmd_handlers.h:274
std::string TAG
Definition: cmd_handlers.h:187
Definition: cmd_handlers.h:160
std::string TAG
Definition: cmd_handlers.h:56
int m_nUserID
Definition: cmd_handlers.h:54
std::string TAG
Definition: cmd_handlers.h:72
std::string m_sEmail
Definition: cmd_handlers.h:52
std::string m_sDescription
Definition: cmd_handlers.h:237
std::string m_sMessage
Definition: cmd_handlers.h:24
IWebSocketServer * m_pServer
Definition: cmd_handlers.h:189
std::string m_sUserUuid
Definition: cmd_handlers.h:55
std::string m_sDeprecatedFromVersion
Definition: cmd_handlers.h:243
std::string m_sCmd
Definition: cmd_handlers.h:236
Global collection with handlers.
Definition: cmd_handlers.h:257
std::string m_sActivatedFromVersion
Definition: cmd_handlers.h:242
std::string m_sMessageId
Definition: cmd_handlers.h:192
IWebSocketServer -.
Definition: cmd_handlers.h:86
WsjcppUserSession * m_pWsjcppUserSession
Definition: cmd_handlers.h:190
WsjcppError(int nCodeError, const std::string &sMessage)
WsjcppError -.
Definition: cmd_handlers.cpp:10
WsjcppError - helper class for errors.
Definition: cmd_handlers.h:18
WsjcppSocketClient -.
Definition: cmd_handlers.h:63
std::string m_sCommand
Definition: cmd_handlers.h:193
std::string TAG
Definition: cmd_handlers.h:235
std::string m_sNick
Definition: cmd_handlers.h:53
bool m_bAccessAdmin
Definition: cmd_handlers.h:246
Definition: wsjcpp_validators.h:47
std::string message()
Definition: cmd_handlers.cpp:23
std::vector< CmdInputDef > m_vInputs
Definition: cmd_handlers.h:240
bool m_bAccessUser
Definition: cmd_handlers.h:245
std::string m_sRole
Definition: cmd_handlers.h:51
int codeError()
Definition: cmd_handlers.cpp:17
Api handler Base.
Definition: cmd_handlers.h:202
QWebSocket * m_pSocket
Definition: cmd_handlers.h:74
QWebSocket * m_pClient
Definition: cmd_handlers.h:188
WsjcppUserSession -.
Definition: cmd_handlers.h:32
int m_nCodeError
Definition: cmd_handlers.h:25
bool m_bAccessUnauthorized
Definition: cmd_handlers.h:244
nlohmann::json m_jsonRequest
Definition: cmd_handlers.h:191