libnxcc: correct handling of CMD_REQUEST_COMPLETED
[public/netxms.git] / include / nxcc.h
1 #ifndef _nxcc_h_
2 #define _nxcc_h_
3
4 #ifdef _WIN32
5 #ifdef LIBNXCC_EXPORTS
6 #define LIBNXCC_EXPORTABLE __declspec(dllexport)
7 #else
8 #define LIBNXCC_EXPORTABLE __declspec(dllimport)
9 #endif
10 #else /* _WIN32 */
11 #define LIBNXCC_EXPORTABLE
12 #endif
13
14 #include <nms_common.h>
15 #include <nms_util.h>
16 #include <nms_threads.h>
17 #include <nxcpapi.h>
18 #include <nxconfig.h>
19
20 /**
21 * Cluster error codes
22 */
23 #define NXCC_RCC_SUCCESS 0
24 #define NXCC_RCC_INVALID_NODE 1
25 #define NXCC_RCC_TIMEOUT 2
26 #define NXCC_RCC_COMM_FAILURE 3
27 #define NXCC_RCC_NOT_MASTER 4
28 #define NXCC_RCC_INVALID_REQUEST 5
29
30 /**
31 * Cluster node states
32 */
33 enum ClusterNodeState
34 {
35 CLUSTER_NODE_DOWN = 0,
36 CLUSTER_NODE_CONNECTED = 1,
37 CLUSTER_NODE_SYNC = 2,
38 CLUSTER_NODE_UP = 3
39 };
40
41 /**
42 * Cluster node event handler
43 */
44 class LIBNXCC_EXPORTABLE ClusterEventHandler
45 {
46 public:
47 ClusterEventHandler();
48 virtual ~ClusterEventHandler();
49
50 virtual void onNodeJoin(UINT32 nodeId);
51 virtual void onNodeUp(UINT32 nodeId);
52 virtual void onNodeDisconnect(UINT32 nodeId);
53 virtual void onShutdown();
54
55 virtual bool onMessage(NXCPMessage *msg, UINT32 sourceNodeId);
56 };
57
58 /**
59 * API functions
60 */
61 bool LIBNXCC_EXPORTABLE ClusterInit(Config *config, const TCHAR *section, ClusterEventHandler *eventHandler);
62 bool LIBNXCC_EXPORTABLE ClusterJoin();
63 void LIBNXCC_EXPORTABLE ClusterSetRunning();
64 void LIBNXCC_EXPORTABLE ClusterShutdown();
65
66 void LIBNXCC_EXPORTABLE ClusterSetDebugCallback(void (*cb)(int, const TCHAR *, va_list));
67
68 UINT32 LIBNXCC_EXPORTABLE ClusterGetLocalNodeId();
69 UINT32 LIBNXCC_EXPORTABLE ClusterGetMasterNodeId();
70 bool LIBNXCC_EXPORTABLE ClusterIsMasterNode();
71 bool LIBNXCC_EXPORTABLE ClusterIsSyncNeeded();
72 bool LIBNXCC_EXPORTABLE ClusterAllNodesConnected();
73
74 void LIBNXCC_EXPORTABLE ClusterNotify(NXCPMessage *msg);
75 void LIBNXCC_EXPORTABLE ClusterNotify(INT16 code);
76 void LIBNXCC_EXPORTABLE ClusterDirectNotify(UINT32 nodeId, INT16 code);
77 int LIBNXCC_EXPORTABLE ClusterSendCommand(NXCPMessage *msg);
78 UINT32 LIBNXCC_EXPORTABLE ClusterSendDirectCommand(UINT32 nodeId, NXCPMessage *msg);
79 NXCPMessage LIBNXCC_EXPORTABLE *ClusterSendDirectCommandEx(UINT32 nodeId, NXCPMessage *msg);
80 void LIBNXCC_EXPORTABLE ClusterSendResponse(UINT32 nodeId, UINT32 requestId, UINT32 rcc);
81 void LIBNXCC_EXPORTABLE ClusterSendResponseEx(UINT32 nodeId, UINT32 requestId, NXCPMessage *msg);
82
83 #endif