diff --git a/dali/dalidiag/dalidiag.cpp b/dali/dalidiag/dalidiag.cpp index 6ffb07ec0c1..dfc9dabcbad 100644 --- a/dali/dalidiag/dalidiag.cpp +++ b/dali/dalidiag/dalidiag.cpp @@ -65,7 +65,7 @@ void usage(const char *exe) printf("-disconnect : -- forcably disconnect a clients connection\n"); printf("-permissions -- get file permissions\n"); printf("-unlock [close] -- forcibly disconnect an sds lock\n"); - printf(" (use id's given by '-locks'\n"); + printf(" (use the ConnectionId in hex given by '-locks'\n"); printf("-settracetransactions -- trace dali transactions\n"); printf("-settraceslowtransactions -- trace slow dali transactions\n"); printf("-cleartracetransactions -- stop tracing dali transactions\n"); diff --git a/esp/scm/ws_dali.ecm b/esp/scm/ws_dali.ecm index ac0240dc27d..0404b14dadf 100644 --- a/esp/scm/ws_dali.ecm +++ b/esp/scm/ws_dali.ecm @@ -151,8 +151,36 @@ ESPrequest [nil_remove] GetSDSSubscribersRequest { }; +ESPrequest [nil_remove] DisconnectClientConnectionRequest +{ + string Endpoint; +}; + +ESPrequest [nil_remove] UnlockSDSLockRequest +{ + string ConnectionID; + bool Close(false); +}; + +ESPrequest [nil_remove] SaveSDSStoreRequest +{ +}; + +ESPrequest [nil_remove] SetTraceTransactionsRequest +{ +}; + +ESPrequest [nil_remove] SetTraceSlowTransactionsRequest +{ + unsigned SlowThresholdMS(1000); //default to 1000 ms +}; + +ESPrequest [nil_remove] ClearTraceTransactionsRequest +{ +}; + ESPservice [auth_feature("NONE"), //This declares that the method logic handles feature level authorization - version("1.05"), default_client_version("1.05"), exceptions_inline("./smc_xslt/exceptions.xslt")] WSDali + version("1.06"), default_client_version("1.06"), exceptions_inline("./smc_xslt/exceptions.xslt")] WSDali { ESPmethod [min_ver("1.01")] SetValue(SetValueRequest, ResultResponse); ESPmethod [min_ver("1.01")] GetValue(GetValueRequest, ResultResponse); @@ -176,6 +204,12 @@ ESPservice [auth_feature("NONE"), //This declares that the method logic handles ESPmethod [min_ver("1.05")] GetClients(GetClientsRequest, ResultResponse); ESPmethod [min_ver("1.05")] GetSDSStats(GetSDSStatsRequest, ResultResponse); ESPmethod [min_ver("1.05")] GetSDSSubscribers(GetSDSSubscribersRequest, ResultResponse); + ESPmethod [min_ver("1.06")] DisconnectClientConnection(DisconnectClientConnectionRequest, ResultResponse); + ESPmethod [min_ver("1.06")] UnlockSDSLock(UnlockSDSLockRequest, ResultResponse); + ESPmethod [min_ver("1.06")] SaveSDSStore(SaveSDSStoreRequest, ResultResponse); + ESPmethod [min_ver("1.06")] SetTraceTransactions(SetTraceTransactionsRequest, ResultResponse); + ESPmethod [min_ver("1.06")] SetTraceSlowTransactions(SetTraceSlowTransactionsRequest, ResultResponse); + ESPmethod [min_ver("1.06")] ClearTraceTransactions(ClearTraceTransactionsRequest, ResultResponse); }; SCMexportdef(WSDali); diff --git a/esp/services/ws_dali/ws_daliservice.cpp b/esp/services/ws_dali/ws_daliservice.cpp index 05cd3c3d16f..9f602878120 100644 --- a/esp/services/ws_dali/ws_daliservice.cpp +++ b/esp/services/ws_dali/ws_daliservice.cpp @@ -594,3 +594,135 @@ bool CWSDaliEx::onGetSDSSubscribers(IEspContext& context, IEspGetSDSSubscribersR } return true; } + +bool CWSDaliEx::onDisconnectClientConnection(IEspContext& context, IEspDisconnectClientConnectionRequest& req, IEspResultResponse& resp) +{ + try + { + checkAccess(context); + + const char* ep = req.getEndpoint(); + if (isEmptyString(ep)) + throw makeStringException(ECLWATCH_INVALID_INPUT, "Endpoint not specified."); + + MemoryBuffer mb; + mb.append("disconnect").append(ep); + getDaliDiagnosticValue(mb); + + VStringBuffer result("DisconnectClientConnection called for %s.", ep); + resp.setResult(result); + } + catch(IException* e) + { + FORWARDEXCEPTION(context, e, ECLWATCH_INTERNAL_ERROR); + } + return true; +} + +bool CWSDaliEx::onUnlockSDSLock(IEspContext& context, IEspUnlockSDSLockRequest& req, IEspResultResponse& resp) +{ + try + { + checkAccess(context); + + const char* connectionIdHex = req.getConnectionID(); + if (isEmptyString(connectionIdHex)) + throw makeStringException(ECLWATCH_INVALID_INPUT, "ConnectionID not specified."); + + MemoryBuffer mb; + mb.append("unlock").append(strtoll(connectionIdHex, nullptr, 16)).append(req.getClose()); + getDaliDiagnosticValue(mb); + + bool success = false; + mb.read(success); + if (!success) + resp.setResult("Lock not found"); + else + { + StringBuffer result(("Lock successfully removed: ")); + mb.read(result); + resp.setResult(result); + } + } + catch(IException* e) + { + FORWARDEXCEPTION(context, e, ECLWATCH_INTERNAL_ERROR); + } + return true; +} + +bool CWSDaliEx::onSaveSDSStore(IEspContext& context, IEspSaveSDSStoreRequest& req, IEspResultResponse& resp) +{ + try + { + checkAccess(context); + + MemoryBuffer mb; + mb.append("save"); + getDaliDiagnosticValue(mb); + resp.setResult("SaveSDSStore called."); + } + catch(IException* e) + { + FORWARDEXCEPTION(context, e, ECLWATCH_INTERNAL_ERROR); + } + return true; +} + +bool CWSDaliEx::onSetTraceTransactions(IEspContext& context, IEspSetTraceTransactionsRequest& req, IEspResultResponse& resp) +{ + try + { + checkAccess(context); + + StringBuffer result; + const char* cmd = "settracetransactions"; + getDaliDiagnosticValue(cmd, result); + resp.setResult(result.isEmpty() ? "SetTraceTransactions called." : result); + } + catch(IException* e) + { + FORWARDEXCEPTION(context, e, ECLWATCH_INTERNAL_ERROR); + } + return true; +} + +bool CWSDaliEx::onSetTraceSlowTransactions(IEspContext& context, IEspSetTraceSlowTransactionsRequest& req, IEspResultResponse& resp) +{ + try + { + checkAccess(context); + + MemoryBuffer mb; + mb.append("settraceslowtransactions"); + mb.append(req.getSlowThresholdMS()); + getDaliDiagnosticValue(mb); + + StringAttr result; + mb.read(result); + resp.setResult(result.isEmpty() ? "SetTraceSlowTransactions called." : result); + } + catch(IException* e) + { + FORWARDEXCEPTION(context, e, ECLWATCH_INTERNAL_ERROR); + } + return true; +} + +bool CWSDaliEx::onClearTraceTransactions(IEspContext& context, IEspClearTraceTransactionsRequest& req, IEspResultResponse& resp) +{ + try + { + checkAccess(context); + + StringBuffer result; + const char* cmd = "cleartracetransactions"; + getDaliDiagnosticValue(cmd, result); + resp.setResult(result.isEmpty() ? "ClearTraceTransactions called." : result); + } + catch(IException* e) + { + FORWARDEXCEPTION(context, e, ECLWATCH_INTERNAL_ERROR); + } + return true; +} diff --git a/esp/services/ws_dali/ws_daliservice.hpp b/esp/services/ws_dali/ws_daliservice.hpp index 272ea0d06fe..3dc43d3d881 100644 --- a/esp/services/ws_dali/ws_daliservice.hpp +++ b/esp/services/ws_dali/ws_daliservice.hpp @@ -72,6 +72,12 @@ class CWSDaliEx : public CWSDali virtual bool onGetClients(IEspContext& context, IEspGetClientsRequest& req, IEspResultResponse& resp) override; virtual bool onGetSDSStats(IEspContext& context, IEspGetSDSStatsRequest& req, IEspResultResponse& resp) override; virtual bool onGetSDSSubscribers(IEspContext& context, IEspGetSDSSubscribersRequest& req, IEspResultResponse& resp) override; + virtual bool onDisconnectClientConnection(IEspContext& context, IEspDisconnectClientConnectionRequest& req, IEspResultResponse& resp) override; + virtual bool onUnlockSDSLock(IEspContext& context, IEspUnlockSDSLockRequest& req, IEspResultResponse& resp) override; + virtual bool onSaveSDSStore(IEspContext& context, IEspSaveSDSStoreRequest& req, IEspResultResponse& resp) override; + virtual bool onSetTraceTransactions(IEspContext& context, IEspSetTraceTransactionsRequest& req, IEspResultResponse& resp) override; + virtual bool onSetTraceSlowTransactions(IEspContext& context, IEspSetTraceSlowTransactionsRequest& req, IEspResultResponse& resp) override; + virtual bool onClearTraceTransactions(IEspContext& context, IEspClearTraceTransactionsRequest& req, IEspResultResponse& resp) override; }; class CWSDaliSoapBindingEx : public CWSDaliSoapBinding