@@ -18,6 +18,7 @@ class WsjcppJsonRpc20Error {
1818 WsjcppJsonRpc20Error (int nErrorCode, const std::string &sErrorMessage );
1919 int getErrorCode ();
2020 std::string getErrorMessage ();
21+ nlohmann::json toJson ();
2122 private:
2223 std::string m_sErrorMessage;
2324 int m_nErrorCode;
@@ -159,10 +160,10 @@ class WsjcppJsonRpc20ParamDef {
159160
160161// ---------------------------------------------------------------------
161162
162- class ModelRequest {
163+ class WsjcppJsonRpc20Request {
163164 public:
164- ModelRequest ( /* QWebSocket *pClient,*/ IWebSocketServer *pWebSocketServer, nlohmann::json &jsonRequest_);
165- // QWebSocket *client();
165+ WsjcppJsonRpc20Request ( void *pClient, IWebSocketServer *pWebSocketServer, nlohmann::json &jsonRequest_);
166+ void *client ();
166167 std::string getIpAddress ();
167168 IWebSocketServer *server ();
168169 WsjcppJsonRpc20UserSession *getUserSession ();
@@ -187,7 +188,7 @@ class ModelRequest {
187188 // bool validateInputParameters(Error &error, CmdHandlerBase *pCmdHandler);
188189 private:
189190 std::string TAG;
190- // QWebSocket *m_pClient;
191+ void *m_pClient;
191192 IWebSocketServer *m_pServer;
192193 WsjcppJsonRpc20UserSession *m_pWsjcppJsonRpc20UserSession;
193194 nlohmann::json m_jsonRequest;
@@ -204,25 +205,27 @@ class ModelRequest {
204205class WsjcppJsonRpc20Base {
205206
206207 public:
207- WsjcppJsonRpc20Base (const std::string &sCmd , const std::string &sDescription );
208- virtual std::string cmd ();
209- virtual std::string description ();
210- std::string activatedFromVersion ();
211- std::string deprecatedFromVersion ();
212- bool accessUnauthorized ();
213- bool accessUser ();
214- bool accessAdmin ();
215- bool checkAccess (ModelRequest *pRequest);
208+ WsjcppJsonRpc20Base (const std::string &sMethod , const std::string &sDescription );
209+ virtual std::string getMethodName () const ;
210+ virtual std::string getDescription () const ;
211+ std::string getActivatedFromVersion () const ;
212+ std::string getDeprecatedFromVersion () const ;
213+ bool getAccessUnauthorized () const ;
214+ bool getAccessUser () const ;
215+ bool getAccessTester () const ;
216+ bool getAccessAdmin () const ;
217+ bool checkAccess (const WsjcppJsonRpc20Request *pRequest) const ;
216218
217219 virtual const std::vector<WsjcppJsonRpc20ParamDef> &inputs ();
218- virtual void handle (ModelRequest *pRequest) = 0;
220+ virtual void handle (WsjcppJsonRpc20Request *pRequest) = 0;
219221
220222 // virtual void done(nlohmann::json jsonResponse);
221223 // virtual void fail(int nCode, const std::string &sErrorMessage);
222224
223225 protected:
224226 void setAccessUnauthorized (bool bAccess);
225227 void setAccessUser (bool bAccess);
228+ void setAccessTester (bool bAccess);
226229 void setAccessAdmin (bool bAccess);
227230 void setActivatedFromVersion (const std::string &sActivatedFromVersion );
228231 void setDeprecatedFromVersion (const std::string &sDeprecatedFromVersion );
@@ -275,7 +278,7 @@ class WsjcppJsonRpc20ServerApi : public WsjcppJsonRpc20Base {
275278
276279 public:
277280 WsjcppJsonRpc20ServerApi ();
278- virtual void handle (ModelRequest *pRequest);
281+ virtual void handle (WsjcppJsonRpc20Request *pRequest);
279282};
280283
281284#endif // WSJCPP_JSONRPC20
0 commit comments