libnxcc: added function ClusterSendResponseEx
authorVictor Kirhenshtein <victor@netxms.org>
Tue, 3 Nov 2015 13:42:06 +0000 (15:42 +0200)
committerVictor Kirhenshtein <victor@netxms.org>
Tue, 3 Nov 2015 13:42:06 +0000 (15:42 +0200)
include/nxcc.h
src/libnxcc/comm.cpp

index b062f8a..3ab254c 100644 (file)
@@ -76,5 +76,6 @@ int LIBNXCC_EXPORTABLE ClusterSendCommand(NXCPMessage *msg);
 UINT32 LIBNXCC_EXPORTABLE ClusterSendDirectCommand(UINT32 nodeId, NXCPMessage *msg);
 NXCPMessage LIBNXCC_EXPORTABLE *ClusterSendDirectCommandEx(UINT32 nodeId, NXCPMessage *msg);
 void LIBNXCC_EXPORTABLE ClusterSendResponse(UINT32 nodeId, UINT32 requestId, UINT32 rcc);
+void LIBNXCC_EXPORTABLE ClusterSendResponseEx(UINT32 nodeId, UINT32 requestId, NXCPMessage *msg);
 
 #endif
index 3dc297f..2e6b954 100644 (file)
@@ -528,7 +528,7 @@ int LIBNXCC_EXPORTABLE ClusterSendCommand(NXCPMessage *msg)
       if (response != NULL)
       {
          UINT32 rcc = response->getFieldAsInt32(VID_RCC);
-         if (rcc != 0)
+         if (rcc != NXCC_RCC_SUCCESS)
          {
             ClusterDebug(5, _T("ClusterCommand: failed request to peer %d [%s] RCC=%d"),
                g_nxccNodes[i].m_id, (const TCHAR *)g_nxccNodes[i].m_addr->toString(), rcc);
@@ -642,6 +642,23 @@ void LIBNXCC_EXPORTABLE ClusterSendResponse(UINT32 nodeId, UINT32 requestId, UIN
 }
 
 /**
+ * Send response to cluster peer
+ */
+void LIBNXCC_EXPORTABLE ClusterSendResponseEx(UINT32 nodeId, UINT32 requestId, NXCPMessage *msg)
+{
+   int index = FindClusterNode(nodeId);
+   if (index == -1)
+      return;
+
+   ClusterNodeInfo *node = &g_nxccNodes[index];
+
+   msg->setCode(CMD_REQUEST_COMPLETED);
+   msg->setId(requestId);
+
+   ClusterSendMessage(node, msg);
+}
+
+/**
  * Check if all cluster nodes connected
  */
 bool LIBNXCC_EXPORTABLE ClusterAllNodesConnected()