mirror of https://github.com/Icinga/icinga2.git
Made build system more Windows-friendly
Implemented endpoint system for the discovery service
This commit is contained in:
parent
8e7787e315
commit
390a00e546
|
@ -3,6 +3,7 @@
|
||||||
|
|
||||||
SUBDIRS = ltdl \
|
SUBDIRS = ltdl \
|
||||||
base \
|
base \
|
||||||
|
cJSON \
|
||||||
jsonrpc \
|
jsonrpc \
|
||||||
configfilecomponent \
|
configfilecomponent \
|
||||||
configrpccomponent \
|
configrpccomponent \
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
|
|
||||||
using namespace icinga;
|
using namespace icinga;
|
||||||
|
|
||||||
Application::Ptr Application::Instance;
|
Application::Ptr I2_EXPORT Application::Instance;
|
||||||
|
|
||||||
Application::Application(void)
|
Application::Application(void)
|
||||||
{
|
{
|
||||||
|
@ -371,3 +371,62 @@ void Application::SigIntHandler(int signum)
|
||||||
sigaction(SIGINT, &sa, NULL);
|
sigaction(SIGINT, &sa, NULL);
|
||||||
#endif /* _WIN32 */
|
#endif /* _WIN32 */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void application_sigint_handler(int signum)
|
||||||
|
{
|
||||||
|
Application::Instance->SigIntHandler(signum);
|
||||||
|
}
|
||||||
|
|
||||||
|
int application_main(int argc, char **argv, Application::Ptr instance)
|
||||||
|
{
|
||||||
|
int result;
|
||||||
|
|
||||||
|
Application::Instance = instance;
|
||||||
|
|
||||||
|
#ifndef _WIN32
|
||||||
|
struct sigaction sa;
|
||||||
|
memset(&sa, 0, sizeof(sa));
|
||||||
|
sa.sa_handler = sigint_handler;
|
||||||
|
sigaction(SIGINT, &sa, NULL);
|
||||||
|
#endif /* _WIN32 */
|
||||||
|
|
||||||
|
vector<string> args;
|
||||||
|
|
||||||
|
for (int i = 0; i < argc; i++)
|
||||||
|
args.push_back(string(argv[i]));
|
||||||
|
|
||||||
|
Application::Instance->SetArguments(args);
|
||||||
|
|
||||||
|
if (Application::Instance->IsDebugging()) {
|
||||||
|
result = Application::Instance->Main(args);
|
||||||
|
} else {
|
||||||
|
try {
|
||||||
|
result = Application::Instance->Main(args);
|
||||||
|
} catch (const Exception& ex) {
|
||||||
|
cout << "---" << endl;
|
||||||
|
|
||||||
|
string klass = typeid(ex).name();
|
||||||
|
|
||||||
|
#ifdef HAVE_GCC_ABI_DEMANGLE
|
||||||
|
int status;
|
||||||
|
char *realname = abi::__cxa_demangle(klass.c_str(), 0, 0, &status);
|
||||||
|
|
||||||
|
if (realname != NULL) {
|
||||||
|
klass = string(realname);
|
||||||
|
free(realname);
|
||||||
|
}
|
||||||
|
#endif /* HAVE_GCC_ABI_DEMANGLE */
|
||||||
|
|
||||||
|
cout << "Exception: " << klass << endl;
|
||||||
|
cout << "Message: " << ex.GetMessage() << endl;
|
||||||
|
|
||||||
|
return EXIT_FAILURE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Application::Instance.reset();
|
||||||
|
|
||||||
|
assert(Object::ActiveObjects == 0);
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
|
@ -7,7 +7,7 @@ class Component;
|
||||||
|
|
||||||
DEFINE_EXCEPTION_CLASS(ComponentLoadException);
|
DEFINE_EXCEPTION_CLASS(ComponentLoadException);
|
||||||
|
|
||||||
class Application : public Object {
|
class I2_BASE_API Application : public Object {
|
||||||
private:
|
private:
|
||||||
bool m_ShuttingDown;
|
bool m_ShuttingDown;
|
||||||
ConfigHive::Ptr m_ConfigHive;
|
ConfigHive::Ptr m_ConfigHive;
|
||||||
|
@ -48,71 +48,14 @@ public:
|
||||||
void SigIntHandler(int signum);
|
void SigIntHandler(int signum);
|
||||||
};
|
};
|
||||||
|
|
||||||
inline void sigint_handler(int signum)
|
|
||||||
{
|
|
||||||
Application::Instance->SigIntHandler(signum);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class T>
|
int I2_EXPORT application_main(int argc, char **argv, icinga::Application::Ptr instance);
|
||||||
int application_main(int argc, char **argv)
|
|
||||||
{
|
|
||||||
int result;
|
|
||||||
|
|
||||||
Application::Instance = make_shared<T>();
|
#define SET_START_CLASS(klass) \
|
||||||
|
int main(int argc, char **argv) { \
|
||||||
#ifndef _WIN32
|
shared_ptr<klass> instance = make_shared<klass>(); \
|
||||||
struct sigaction sa;
|
return application_main(argc, argv, instance); \
|
||||||
memset(&sa, 0, sizeof(sa));
|
|
||||||
sa.sa_handler = sigint_handler;
|
|
||||||
sigaction(SIGINT, &sa, NULL);
|
|
||||||
#endif /* _WIN32 */
|
|
||||||
|
|
||||||
vector<string> args;
|
|
||||||
|
|
||||||
for (int i = 0; i < argc; i++)
|
|
||||||
args.push_back(string(argv[i]));
|
|
||||||
|
|
||||||
Application::Instance->SetArguments(args);
|
|
||||||
|
|
||||||
if (Application::Instance->IsDebugging()) {
|
|
||||||
result = Application::Instance->Main(args);
|
|
||||||
} else {
|
|
||||||
try {
|
|
||||||
result = Application::Instance->Main(args);
|
|
||||||
} catch (const Exception& ex) {
|
|
||||||
cout << "---" << endl;
|
|
||||||
|
|
||||||
string klass = typeid(ex).name();
|
|
||||||
|
|
||||||
#ifdef HAVE_GCC_ABI_DEMANGLE
|
|
||||||
int status;
|
|
||||||
char *realname = abi::__cxa_demangle(klass.c_str(), 0, 0, &status);
|
|
||||||
|
|
||||||
if (realname != NULL) {
|
|
||||||
klass = string(realname);
|
|
||||||
free(realname);
|
|
||||||
}
|
|
||||||
#endif /* HAVE_GCC_ABI_DEMANGLE */
|
|
||||||
|
|
||||||
cout << "Exception: " << klass << endl;
|
|
||||||
cout << "Message: " << ex.GetMessage() << endl;
|
|
||||||
|
|
||||||
return EXIT_FAILURE;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Application::Instance.reset();
|
|
||||||
|
|
||||||
assert(Object::ActiveObjects == 0);
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
#define SET_START_CLASS(klass) \
|
|
||||||
int main(int argc, char **argv) { \
|
|
||||||
return application_main<klass>(argc, argv); \
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif /* APPLICATION_H */
|
#endif /* APPLICATION_H */
|
||||||
|
|
|
@ -65,7 +65,7 @@
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||||
<UseDebugLibraries>true</UseDebugLibraries>
|
<UseDebugLibraries>true</UseDebugLibraries>
|
||||||
<CharacterSet>MultiByte</CharacterSet>
|
<CharacterSet>MultiByte</CharacterSet>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
@ -73,7 +73,7 @@
|
||||||
<UseDebugLibraries>false</UseDebugLibraries>
|
<UseDebugLibraries>false</UseDebugLibraries>
|
||||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||||
<CharacterSet>MultiByte</CharacterSet>
|
<CharacterSet>MultiByte</CharacterSet>
|
||||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||||
<ImportGroup Label="ExtensionSettings">
|
<ImportGroup Label="ExtensionSettings">
|
||||||
|
@ -92,11 +92,12 @@
|
||||||
</PrecompiledHeader>
|
</PrecompiledHeader>
|
||||||
<WarningLevel>Level3</WarningLevel>
|
<WarningLevel>Level3</WarningLevel>
|
||||||
<Optimization>Disabled</Optimization>
|
<Optimization>Disabled</Optimization>
|
||||||
|
<PreprocessorDefinitions>_WINDLL;I2_BASE_BUILD;_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<SubSystem>Windows</SubSystem>
|
<SubSystem>Windows</SubSystem>
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
<AdditionalDependencies>ws2_32.lib;imagehlp.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
<AdditionalDependencies>ws2_32.lib;shlwapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||||
</Link>
|
</Link>
|
||||||
<Lib>
|
<Lib>
|
||||||
<AdditionalDependencies>ws2_32.lib;shlwapi.lib</AdditionalDependencies>
|
<AdditionalDependencies>ws2_32.lib;shlwapi.lib</AdditionalDependencies>
|
||||||
|
@ -110,13 +111,14 @@
|
||||||
<Optimization>MaxSpeed</Optimization>
|
<Optimization>MaxSpeed</Optimization>
|
||||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||||
|
<PreprocessorDefinitions>_WINDLL;I2_BASE_BUILD;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<SubSystem>Windows</SubSystem>
|
<SubSystem>Windows</SubSystem>
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||||
<OptimizeReferences>true</OptimizeReferences>
|
<OptimizeReferences>true</OptimizeReferences>
|
||||||
<AdditionalDependencies>ws2_32.lib;imagehlp.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
<AdditionalDependencies>ws2_32.lib;shlwapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||||
</Link>
|
</Link>
|
||||||
<Lib>
|
<Lib>
|
||||||
<AdditionalDependencies>ws2_32.lib;shlwapi.lib</AdditionalDependencies>
|
<AdditionalDependencies>ws2_32.lib;shlwapi.lib</AdditionalDependencies>
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
namespace icinga
|
namespace icinga
|
||||||
{
|
{
|
||||||
|
|
||||||
class Component : public Object
|
class I2_BASE_API Component : public Object
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
Application::WeakPtr m_Application;
|
Application::WeakPtr m_Application;
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
namespace icinga
|
namespace icinga
|
||||||
{
|
{
|
||||||
|
|
||||||
class condvar
|
class I2_BASE_API condvar
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
|
|
|
@ -6,7 +6,7 @@ namespace icinga
|
||||||
|
|
||||||
class ConfigHive;
|
class ConfigHive;
|
||||||
|
|
||||||
class ConfigCollection : public Object
|
class I2_BASE_API ConfigCollection : public Object
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
weak_ptr<ConfigHive> m_Hive;
|
weak_ptr<ConfigHive> m_Hive;
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
namespace icinga
|
namespace icinga
|
||||||
{
|
{
|
||||||
|
|
||||||
class ConfigHive : public Object
|
class I2_BASE_API ConfigHive : public Object
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
typedef shared_ptr<ConfigHive> Ptr;
|
typedef shared_ptr<ConfigHive> Ptr;
|
||||||
|
|
|
@ -8,7 +8,7 @@ namespace icinga
|
||||||
|
|
||||||
class ConfigHive;
|
class ConfigHive;
|
||||||
|
|
||||||
struct ConfigObjectEventArgs : public EventArgs
|
struct I2_BASE_API ConfigObjectEventArgs : public EventArgs
|
||||||
{
|
{
|
||||||
typedef shared_ptr<ConfigObjectEventArgs> Ptr;
|
typedef shared_ptr<ConfigObjectEventArgs> Ptr;
|
||||||
typedef weak_ptr<ConfigObjectEventArgs> WeakPtr;
|
typedef weak_ptr<ConfigObjectEventArgs> WeakPtr;
|
||||||
|
@ -17,7 +17,7 @@ struct ConfigObjectEventArgs : public EventArgs
|
||||||
string OldValue;
|
string OldValue;
|
||||||
};
|
};
|
||||||
|
|
||||||
class ConfigObject : public Object
|
class I2_BASE_API ConfigObject : public Object
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
weak_ptr<ConfigHive> m_Hive;
|
weak_ptr<ConfigHive> m_Hive;
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
namespace icinga
|
namespace icinga
|
||||||
{
|
{
|
||||||
|
|
||||||
struct EventArgs : public Object
|
struct I2_BASE_API EventArgs : public Object
|
||||||
{
|
{
|
||||||
typedef shared_ptr<EventArgs> Ptr;
|
typedef shared_ptr<EventArgs> Ptr;
|
||||||
typedef weak_ptr<EventArgs> WeakPtr;
|
typedef weak_ptr<EventArgs> WeakPtr;
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
namespace icinga
|
namespace icinga
|
||||||
{
|
{
|
||||||
|
|
||||||
class Exception
|
class I2_BASE_API Exception
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
string m_Message;
|
string m_Message;
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
namespace icinga
|
namespace icinga
|
||||||
{
|
{
|
||||||
|
|
||||||
class FIFO : public Object
|
class I2_BASE_API FIFO : public Object
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
char *m_Buffer;
|
char *m_Buffer;
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
|
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
# define HAVE_CXX11
|
# define HAVE_CXX11
|
||||||
|
# pragma warning(disable:4251)
|
||||||
#else /* _MSC_VER */
|
#else /* _MSC_VER */
|
||||||
# include "config.h"
|
# include "config.h"
|
||||||
#endif /* _MSC_VER */
|
#endif /* _MSC_VER */
|
||||||
|
@ -55,6 +56,12 @@ using namespace std::tr1::placeholders;
|
||||||
# include "unix.h"
|
# include "unix.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef I2_BASE_BUILD
|
||||||
|
# define I2_BASE_API I2_EXPORT
|
||||||
|
#else /* I2_BASE_BUILD */
|
||||||
|
# define I2_BASE_API I2_IMPORT
|
||||||
|
#endif /* I2_BASE_BUILD */
|
||||||
|
|
||||||
#include "mutex.h"
|
#include "mutex.h"
|
||||||
#include "condvar.h"
|
#include "condvar.h"
|
||||||
#include "thread.h"
|
#include "thread.h"
|
||||||
|
|
|
@ -6,7 +6,7 @@ namespace icinga
|
||||||
|
|
||||||
DEFINE_EXCEPTION_CLASS(OutOfMemoryException);
|
DEFINE_EXCEPTION_CLASS(OutOfMemoryException);
|
||||||
|
|
||||||
class Memory
|
class I2_BASE_API Memory
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
Memory(void);
|
Memory(void);
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
namespace icinga
|
namespace icinga
|
||||||
{
|
{
|
||||||
|
|
||||||
class mutex
|
class I2_BASE_API mutex
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
|
|
|
@ -4,21 +4,20 @@
|
||||||
namespace icinga
|
namespace icinga
|
||||||
{
|
{
|
||||||
|
|
||||||
class Object : public enable_shared_from_this<Object>
|
class I2_BASE_API Object : public enable_shared_from_this<Object>
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
Object(const Object &other);
|
Object(const Object &other);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
Object(void);
|
Object(void);
|
||||||
|
virtual ~Object(void);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
typedef shared_ptr<Object> Ptr;
|
typedef shared_ptr<Object> Ptr;
|
||||||
typedef weak_ptr<Object> WeakPtr;
|
typedef weak_ptr<Object> WeakPtr;
|
||||||
|
|
||||||
static unsigned long ActiveObjects;
|
static unsigned long ActiveObjects;
|
||||||
|
|
||||||
virtual ~Object(void);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
|
|
||||||
namespace icinga {
|
namespace icinga {
|
||||||
|
|
||||||
struct SocketErrorEventArgs : public EventArgs
|
struct I2_BASE_API SocketErrorEventArgs : public EventArgs
|
||||||
{
|
{
|
||||||
typedef shared_ptr<SocketErrorEventArgs> Ptr;
|
typedef shared_ptr<SocketErrorEventArgs> Ptr;
|
||||||
typedef weak_ptr<SocketErrorEventArgs> WeakPtr;
|
typedef weak_ptr<SocketErrorEventArgs> WeakPtr;
|
||||||
|
@ -12,7 +12,7 @@ struct SocketErrorEventArgs : public EventArgs
|
||||||
string Message;
|
string Message;
|
||||||
};
|
};
|
||||||
|
|
||||||
class Socket : public Object
|
class I2_BASE_API Socket : public Object
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
SOCKET m_FD;
|
SOCKET m_FD;
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
namespace icinga
|
namespace icinga
|
||||||
{
|
{
|
||||||
|
|
||||||
class TCPClient : public TCPSocket
|
class I2_BASE_API TCPClient : public TCPSocket
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
string m_PeerHost;
|
string m_PeerHost;
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
namespace icinga
|
namespace icinga
|
||||||
{
|
{
|
||||||
|
|
||||||
struct NewClientEventArgs : public EventArgs
|
struct I2_BASE_API NewClientEventArgs : public EventArgs
|
||||||
{
|
{
|
||||||
typedef shared_ptr<NewClientEventArgs> Ptr;
|
typedef shared_ptr<NewClientEventArgs> Ptr;
|
||||||
typedef weak_ptr<NewClientEventArgs> WeakPtr;
|
typedef weak_ptr<NewClientEventArgs> WeakPtr;
|
||||||
|
@ -12,7 +12,7 @@ struct NewClientEventArgs : public EventArgs
|
||||||
TCPSocket::Ptr Client;
|
TCPSocket::Ptr Client;
|
||||||
};
|
};
|
||||||
|
|
||||||
class TCPServer : public TCPSocket
|
class I2_BASE_API TCPServer : public TCPSocket
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
int ReadableEventHandler(EventArgs::Ptr ea);
|
int ReadableEventHandler(EventArgs::Ptr ea);
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
namespace icinga
|
namespace icinga
|
||||||
{
|
{
|
||||||
|
|
||||||
class TCPSocket : public Socket
|
class I2_BASE_API TCPSocket : public Socket
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
typedef shared_ptr<TCPSocket> Ptr;
|
typedef shared_ptr<TCPSocket> Ptr;
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
namespace icinga
|
namespace icinga
|
||||||
{
|
{
|
||||||
|
|
||||||
class thread
|
class I2_BASE_API thread
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
|
|
||||||
namespace icinga {
|
namespace icinga {
|
||||||
|
|
||||||
struct TimerEventArgs : public EventArgs
|
struct I2_BASE_API TimerEventArgs : public EventArgs
|
||||||
{
|
{
|
||||||
typedef shared_ptr<TimerEventArgs> Ptr;
|
typedef shared_ptr<TimerEventArgs> Ptr;
|
||||||
typedef weak_ptr<TimerEventArgs> WeakPtr;
|
typedef weak_ptr<TimerEventArgs> WeakPtr;
|
||||||
|
@ -13,7 +13,7 @@ struct TimerEventArgs : public EventArgs
|
||||||
EventArgs::Ptr UserArgs;
|
EventArgs::Ptr UserArgs;
|
||||||
};
|
};
|
||||||
|
|
||||||
class Timer : public Object
|
class I2_BASE_API Timer : public Object
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
EventArgs::Ptr m_UserArgs;
|
EventArgs::Ptr m_UserArgs;
|
||||||
|
|
|
@ -0,0 +1,9 @@
|
||||||
|
## Process this file with automake to produce Makefile.in
|
||||||
|
|
||||||
|
|
||||||
|
noinst_LTLIBRARIES = \
|
||||||
|
libcJSON.la
|
||||||
|
|
||||||
|
libcJSON_la_SOURCES = \
|
||||||
|
cJSON.c \
|
||||||
|
cJSON.h
|
|
@ -0,0 +1,80 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<ItemGroup Label="ProjectConfigurations">
|
||||||
|
<ProjectConfiguration Include="Debug|Win32">
|
||||||
|
<Configuration>Debug</Configuration>
|
||||||
|
<Platform>Win32</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
<ProjectConfiguration Include="Release|Win32">
|
||||||
|
<Configuration>Release</Configuration>
|
||||||
|
<Platform>Win32</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ClCompile Include="cJSON.c" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ClInclude Include="cJSON.h" />
|
||||||
|
</ItemGroup>
|
||||||
|
<PropertyGroup Label="Globals">
|
||||||
|
<ProjectGuid>{66BED474-C33F-48F9-90BA-BBCFEDC006B8}</ProjectGuid>
|
||||||
|
<Keyword>Win32Proj</Keyword>
|
||||||
|
<RootNamespace>cJSON</RootNamespace>
|
||||||
|
</PropertyGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||||
|
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||||
|
<UseDebugLibraries>true</UseDebugLibraries>
|
||||||
|
<CharacterSet>Unicode</CharacterSet>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||||
|
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||||
|
<UseDebugLibraries>false</UseDebugLibraries>
|
||||||
|
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||||
|
<CharacterSet>Unicode</CharacterSet>
|
||||||
|
</PropertyGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||||
|
<ImportGroup Label="ExtensionSettings">
|
||||||
|
</ImportGroup>
|
||||||
|
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||||
|
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||||
|
</ImportGroup>
|
||||||
|
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||||
|
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||||
|
</ImportGroup>
|
||||||
|
<PropertyGroup Label="UserMacros" />
|
||||||
|
<PropertyGroup />
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||||
|
<ClCompile>
|
||||||
|
<PrecompiledHeader>
|
||||||
|
</PrecompiledHeader>
|
||||||
|
<WarningLevel>Level3</WarningLevel>
|
||||||
|
<Optimization>Disabled</Optimization>
|
||||||
|
<PreprocessorDefinitions>WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<SubSystem>Windows</SubSystem>
|
||||||
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
|
</Link>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||||
|
<ClCompile>
|
||||||
|
<WarningLevel>Level3</WarningLevel>
|
||||||
|
<PrecompiledHeader>
|
||||||
|
</PrecompiledHeader>
|
||||||
|
<Optimization>MaxSpeed</Optimization>
|
||||||
|
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||||
|
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||||
|
<PreprocessorDefinitions>WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<SubSystem>Windows</SubSystem>
|
||||||
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
|
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||||
|
<OptimizeReferences>true</OptimizeReferences>
|
||||||
|
</Link>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||||
|
<ImportGroup Label="ExtensionTargets">
|
||||||
|
</ImportGroup>
|
||||||
|
</Project>
|
|
@ -11,4 +11,4 @@ libconfigfilecomponent_la_SOURCES = \
|
||||||
libconfigfilecomponent_la_CXXFLAGS = -I${top_srcdir}/base -I${top_srcdir}/jsonrpc
|
libconfigfilecomponent_la_CXXFLAGS = -I${top_srcdir}/base -I${top_srcdir}/jsonrpc
|
||||||
|
|
||||||
libconfigfilecomponent_la_LDFLAGS = -module -version-info 0:0:0 -no-undefined
|
libconfigfilecomponent_la_LDFLAGS = -module -version-info 0:0:0 -no-undefined
|
||||||
libconfigfilecomponent_la_LIBADD = ${top_builddir}/base/libbase.la ${top_builddir}/jsonrpc/libjsonrpc.la
|
libconfigfilecomponent_la_LIBADD = ${top_builddir}/base/libbase.la ${top_builddir}/cJSON/libcJSON.la
|
|
@ -45,11 +45,11 @@
|
||||||
</ImportGroup>
|
</ImportGroup>
|
||||||
<PropertyGroup Label="UserMacros" />
|
<PropertyGroup Label="UserMacros" />
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||||
<IncludePath>$(ProjectDir)\..\base;$(ProjectDir)\..\jsonrpc;$(IncludePath)</IncludePath>
|
<IncludePath>$(ProjectDir)\..\base;$(ProjectDir)\..\cJSON;$(IncludePath)</IncludePath>
|
||||||
<LibraryPath>$(OutDir);$(LibraryPath)</LibraryPath>
|
<LibraryPath>$(OutDir);$(LibraryPath)</LibraryPath>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||||
<IncludePath>$(ProjectDir)\..\base;$(ProjectDir)\..\jsonrpc;$(IncludePath)</IncludePath>
|
<IncludePath>$(ProjectDir)\..\base;$(ProjectDir)\..\cJSON;$(IncludePath)</IncludePath>
|
||||||
<LibraryPath>$(OutDir);$(LibraryPath)</LibraryPath>
|
<LibraryPath>$(OutDir);$(LibraryPath)</LibraryPath>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||||
|
@ -63,7 +63,7 @@
|
||||||
<Link>
|
<Link>
|
||||||
<SubSystem>Windows</SubSystem>
|
<SubSystem>Windows</SubSystem>
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
<AdditionalDependencies>base.lib;jsonrpc.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
<AdditionalDependencies>base.lib;jsonrpc.lib;cJSON.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||||
</Link>
|
</Link>
|
||||||
<Lib>
|
<Lib>
|
||||||
<AdditionalDependencies>
|
<AdditionalDependencies>
|
||||||
|
@ -85,7 +85,7 @@
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||||
<OptimizeReferences>true</OptimizeReferences>
|
<OptimizeReferences>true</OptimizeReferences>
|
||||||
<AdditionalDependencies>base.lib;jsonrpc.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
<AdditionalDependencies>base.lib;jsonrpc.lib;cJSON.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||||
</Link>
|
</Link>
|
||||||
<Lib>
|
<Lib>
|
||||||
<AdditionalDependencies>$(OutDir)\base.lib;$(OutDir)\jsonrpc.lib</AdditionalDependencies>
|
<AdditionalDependencies>$(OutDir)\base.lib;$(OutDir)\jsonrpc.lib</AdditionalDependencies>
|
||||||
|
|
|
@ -11,4 +11,6 @@ libconfigrpccomponent_la_SOURCES = \
|
||||||
libconfigrpccomponent_la_CXXFLAGS = -I${top_srcdir}/base -I${top_srcdir}/jsonrpc -I${top_srcdir}/icinga
|
libconfigrpccomponent_la_CXXFLAGS = -I${top_srcdir}/base -I${top_srcdir}/jsonrpc -I${top_srcdir}/icinga
|
||||||
|
|
||||||
libconfigrpccomponent_la_LDFLAGS = -module -version-info 0:0:0 -no-undefined -pthread
|
libconfigrpccomponent_la_LDFLAGS = -module -version-info 0:0:0 -no-undefined -pthread
|
||||||
libconfigrpccomponent_la_LIBADD = ${top_builddir}/base/libbase.la ${top_builddir}/jsonrpc/libjsonrpc.la
|
libconfigrpccomponent_la_LIBADD = ${top_builddir}/base/libbase.la \
|
||||||
|
${top_builddir}/jsonrpc/libjsonrpc.la \
|
||||||
|
${top_builddir}/cJSON/libcJSON.la
|
||||||
|
|
|
@ -16,21 +16,29 @@ void ConfigRpcComponent::Start(void)
|
||||||
{
|
{
|
||||||
IcingaApplication::Ptr icingaApp = GetIcingaApplication();
|
IcingaApplication::Ptr icingaApp = GetIcingaApplication();
|
||||||
|
|
||||||
ConnectionManager::Ptr connectionManager = icingaApp->GetConnectionManager();
|
EndpointManager::Ptr endpointManager = icingaApp->GetEndpointManager();
|
||||||
ConfigHive::Ptr configHive = icingaApp->GetConfigHive();
|
ConfigHive::Ptr configHive = icingaApp->GetConfigHive();
|
||||||
|
|
||||||
|
m_ConfigRpcEndpoint = make_shared<VirtualEndpoint>();
|
||||||
|
|
||||||
int configSource;
|
int configSource;
|
||||||
if (GetConfig()->GetPropertyInteger("configSource", &configSource) && configSource != 0) {
|
if (GetConfig()->GetPropertyInteger("configSource", &configSource) && configSource != 0) {
|
||||||
connectionManager->RegisterMethod("config::FetchObjects", bind_weak(&ConfigRpcComponent::FetchObjectsHandler, shared_from_this()));
|
m_ConfigRpcEndpoint->RegisterMethodHandler("config::FetchObjects", bind_weak(&ConfigRpcComponent::FetchObjectsHandler, shared_from_this()));
|
||||||
|
|
||||||
configHive->OnObjectCreated += bind_weak(&ConfigRpcComponent::LocalObjectCreatedHandler, shared_from_this());
|
configHive->OnObjectCreated += bind_weak(&ConfigRpcComponent::LocalObjectCreatedHandler, shared_from_this());
|
||||||
configHive->OnObjectRemoved += bind_weak(&ConfigRpcComponent::LocalObjectRemovedHandler, shared_from_this());
|
configHive->OnObjectRemoved += bind_weak(&ConfigRpcComponent::LocalObjectRemovedHandler, shared_from_this());
|
||||||
configHive->OnPropertyChanged += bind_weak(&ConfigRpcComponent::LocalPropertyChangedHandler, shared_from_this());
|
configHive->OnPropertyChanged += bind_weak(&ConfigRpcComponent::LocalPropertyChangedHandler, shared_from_this());
|
||||||
|
|
||||||
|
m_ConfigRpcEndpoint->RegisterMethodSource("config::ObjectCreated");
|
||||||
|
m_ConfigRpcEndpoint->RegisterMethodSource("config::ObjectRemoved");
|
||||||
|
m_ConfigRpcEndpoint->RegisterMethodSource("config::PropertyChanged");
|
||||||
}
|
}
|
||||||
|
|
||||||
connectionManager->RegisterMethod("config::ObjectCreated", bind_weak(&ConfigRpcComponent::RemoteObjectUpdatedHandler, shared_from_this()));
|
m_ConfigRpcEndpoint->RegisterMethodHandler("config::ObjectCreated", bind_weak(&ConfigRpcComponent::RemoteObjectUpdatedHandler, shared_from_this()));
|
||||||
connectionManager->RegisterMethod("config::ObjectRemoved", bind_weak(&ConfigRpcComponent::RemoteObjectRemovedHandler, shared_from_this()));
|
m_ConfigRpcEndpoint->RegisterMethodHandler("config::ObjectRemoved", bind_weak(&ConfigRpcComponent::RemoteObjectRemovedHandler, shared_from_this()));
|
||||||
connectionManager->RegisterMethod("config::PropertyChanged", bind_weak(&ConfigRpcComponent::RemoteObjectUpdatedHandler, shared_from_this()));
|
m_ConfigRpcEndpoint->RegisterMethodHandler("config::PropertyChanged", bind_weak(&ConfigRpcComponent::RemoteObjectUpdatedHandler, shared_from_this()));
|
||||||
|
|
||||||
|
endpointManager->RegisterEndpoint(m_ConfigRpcEndpoint);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConfigRpcComponent::Stop(void)
|
void ConfigRpcComponent::Stop(void)
|
||||||
|
@ -88,8 +96,8 @@ int ConfigRpcComponent::LocalObjectCreatedHandler(ConfigObjectEventArgs::Ptr ea)
|
||||||
object->GetPropertyInteger("replicate", &replicate);
|
object->GetPropertyInteger("replicate", &replicate);
|
||||||
|
|
||||||
if (replicate) {
|
if (replicate) {
|
||||||
ConnectionManager::Ptr connectionManager = GetIcingaApplication()->GetConnectionManager();
|
EndpointManager::Ptr mgr = GetIcingaApplication()->GetEndpointManager();
|
||||||
connectionManager->SendMessage(MakeObjectMessage(object, "config::ObjectCreated", true));
|
mgr->SendMessage(m_ConfigRpcEndpoint, NULL, MakeObjectMessage(object, "config::ObjectCreated", true));
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -103,8 +111,8 @@ int ConfigRpcComponent::LocalObjectRemovedHandler(ConfigObjectEventArgs::Ptr ea)
|
||||||
object->GetPropertyInteger("replicate", &replicate);
|
object->GetPropertyInteger("replicate", &replicate);
|
||||||
|
|
||||||
if (replicate) {
|
if (replicate) {
|
||||||
ConnectionManager::Ptr connectionManager = GetIcingaApplication()->GetConnectionManager();
|
EndpointManager::Ptr mgr = GetIcingaApplication()->GetEndpointManager();
|
||||||
connectionManager->SendMessage(MakeObjectMessage(object, "config::ObjectRemoved", false));
|
mgr->SendMessage(m_ConfigRpcEndpoint, NULL, MakeObjectMessage(object, "config::ObjectRemoved", false));
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -129,8 +137,8 @@ int ConfigRpcComponent::LocalPropertyChangedHandler(ConfigObjectEventArgs::Ptr e
|
||||||
|
|
||||||
cJSON_AddStringToObject(properties, ea->Property.c_str(), value.c_str());
|
cJSON_AddStringToObject(properties, ea->Property.c_str(), value.c_str());
|
||||||
|
|
||||||
ConnectionManager::Ptr connectionManager = GetIcingaApplication()->GetConnectionManager();
|
EndpointManager::Ptr mgr = GetIcingaApplication()->GetEndpointManager();
|
||||||
connectionManager->SendMessage(msg);
|
mgr->SendMessage(m_ConfigRpcEndpoint, NULL, msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -7,6 +7,8 @@ namespace icinga
|
||||||
class ConfigRpcComponent : public Component
|
class ConfigRpcComponent : public Component
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
|
VirtualEndpoint::Ptr m_ConfigRpcEndpoint;
|
||||||
|
|
||||||
IcingaApplication::Ptr GetIcingaApplication(void);
|
IcingaApplication::Ptr GetIcingaApplication(void);
|
||||||
|
|
||||||
int FetchObjectsHandler(NewMessageEventArgs::Ptr ea);
|
int FetchObjectsHandler(NewMessageEventArgs::Ptr ea);
|
||||||
|
|
|
@ -46,12 +46,12 @@
|
||||||
<PropertyGroup Label="UserMacros" />
|
<PropertyGroup Label="UserMacros" />
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||||
<LinkIncremental>true</LinkIncremental>
|
<LinkIncremental>true</LinkIncremental>
|
||||||
<IncludePath>$(ProjectDir)\..\base;$(ProjectDir)\..\jsonrpc;$(ProjectDir)\..\icinga;$(IncludePath)</IncludePath>
|
<IncludePath>$(ProjectDir)\..\base;$(ProjectDir)\..\jsonrpc;$(ProjectDir)\..\icinga;$(ProjectDir)\..\cJSON;$(IncludePath)</IncludePath>
|
||||||
<LibraryPath>$(OutDir);$(LibraryPath)</LibraryPath>
|
<LibraryPath>$(OutDir);$(LibraryPath)</LibraryPath>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||||
<LinkIncremental>false</LinkIncremental>
|
<LinkIncremental>false</LinkIncremental>
|
||||||
<IncludePath>$(ProjectDir)\..\base;$(ProjectDir)\..\jsonrpc;$(ProjectDir)\..\icinga;$(IncludePath)</IncludePath>
|
<IncludePath>$(ProjectDir)\..\base;$(ProjectDir)\..\jsonrpc;$(ProjectDir)\..\icinga;$(ProjectDir)\..\cJSON;$(IncludePath)</IncludePath>
|
||||||
<LibraryPath>$(OutDir);$(LibraryPath)</LibraryPath>
|
<LibraryPath>$(OutDir);$(LibraryPath)</LibraryPath>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||||
|
@ -65,7 +65,7 @@
|
||||||
<Link>
|
<Link>
|
||||||
<SubSystem>Windows</SubSystem>
|
<SubSystem>Windows</SubSystem>
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
<AdditionalDependencies>base.lib;jsonrpc.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
<AdditionalDependencies>base.lib;jsonrpc.lib;icinga.lib;cJSON.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||||
</Link>
|
</Link>
|
||||||
</ItemDefinitionGroup>
|
</ItemDefinitionGroup>
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||||
|
@ -83,7 +83,7 @@
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||||
<OptimizeReferences>true</OptimizeReferences>
|
<OptimizeReferences>true</OptimizeReferences>
|
||||||
<AdditionalDependencies>base.lib;jsonrpc.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
<AdditionalDependencies>base.lib;jsonrpc.lib;icinga.lib;cJSON.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||||
</Link>
|
</Link>
|
||||||
</ItemDefinitionGroup>
|
</ItemDefinitionGroup>
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||||
|
|
|
@ -43,6 +43,7 @@ fi
|
||||||
AC_OUTPUT([
|
AC_OUTPUT([
|
||||||
Makefile
|
Makefile
|
||||||
base/Makefile
|
base/Makefile
|
||||||
|
cJSON/Makefile
|
||||||
configfilecomponent/Makefile
|
configfilecomponent/Makefile
|
||||||
configrpccomponent/Makefile
|
configrpccomponent/Makefile
|
||||||
icinga/Makefile
|
icinga/Makefile
|
||||||
|
|
14
icinga.sln
14
icinga.sln
|
@ -5,6 +5,7 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "base", "base\base.vcxproj",
|
||||||
EndProject
|
EndProject
|
||||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "jsonrpc", "jsonrpc\jsonrpc.vcxproj", "{8DD52FAC-ECEE-48C2-B266-E7C47ED485F8}"
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "jsonrpc", "jsonrpc\jsonrpc.vcxproj", "{8DD52FAC-ECEE-48C2-B266-E7C47ED485F8}"
|
||||||
ProjectSection(ProjectDependencies) = postProject
|
ProjectSection(ProjectDependencies) = postProject
|
||||||
|
{66BED474-C33F-48F9-90BA-BBCFEDC006B8} = {66BED474-C33F-48F9-90BA-BBCFEDC006B8}
|
||||||
{9C92DA90-FD53-43A9-A244-90F2E8AF9677} = {9C92DA90-FD53-43A9-A244-90F2E8AF9677}
|
{9C92DA90-FD53-43A9-A244-90F2E8AF9677} = {9C92DA90-FD53-43A9-A244-90F2E8AF9677}
|
||||||
EndProjectSection
|
EndProjectSection
|
||||||
EndProject
|
EndProject
|
||||||
|
@ -15,24 +16,29 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
|
||||||
EndProject
|
EndProject
|
||||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "icinga", "icinga\icinga.vcxproj", "{C1FC77E1-04A4-481B-A78B-2F7AF489C2F8}"
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "icinga", "icinga\icinga.vcxproj", "{C1FC77E1-04A4-481B-A78B-2F7AF489C2F8}"
|
||||||
ProjectSection(ProjectDependencies) = postProject
|
ProjectSection(ProjectDependencies) = postProject
|
||||||
{697C6D7E-3109-484C-A7AF-384D28711610} = {697C6D7E-3109-484C-A7AF-384D28711610}
|
{66BED474-C33F-48F9-90BA-BBCFEDC006B8} = {66BED474-C33F-48F9-90BA-BBCFEDC006B8}
|
||||||
{9C92DA90-FD53-43A9-A244-90F2E8AF9677} = {9C92DA90-FD53-43A9-A244-90F2E8AF9677}
|
{9C92DA90-FD53-43A9-A244-90F2E8AF9677} = {9C92DA90-FD53-43A9-A244-90F2E8AF9677}
|
||||||
{E58F1DA7-B723-412B-B2B7-7FF58E2A944E} = {E58F1DA7-B723-412B-B2B7-7FF58E2A944E}
|
|
||||||
{8DD52FAC-ECEE-48C2-B266-E7C47ED485F8} = {8DD52FAC-ECEE-48C2-B266-E7C47ED485F8}
|
{8DD52FAC-ECEE-48C2-B266-E7C47ED485F8} = {8DD52FAC-ECEE-48C2-B266-E7C47ED485F8}
|
||||||
EndProjectSection
|
EndProjectSection
|
||||||
EndProject
|
EndProject
|
||||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "configfilecomponent", "configfilecomponent\configfilecomponent.vcxproj", "{E58F1DA7-B723-412B-B2B7-7FF58E2A944E}"
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "configfilecomponent", "configfilecomponent\configfilecomponent.vcxproj", "{E58F1DA7-B723-412B-B2B7-7FF58E2A944E}"
|
||||||
ProjectSection(ProjectDependencies) = postProject
|
ProjectSection(ProjectDependencies) = postProject
|
||||||
|
{66BED474-C33F-48F9-90BA-BBCFEDC006B8} = {66BED474-C33F-48F9-90BA-BBCFEDC006B8}
|
||||||
{9C92DA90-FD53-43A9-A244-90F2E8AF9677} = {9C92DA90-FD53-43A9-A244-90F2E8AF9677}
|
{9C92DA90-FD53-43A9-A244-90F2E8AF9677} = {9C92DA90-FD53-43A9-A244-90F2E8AF9677}
|
||||||
{8DD52FAC-ECEE-48C2-B266-E7C47ED485F8} = {8DD52FAC-ECEE-48C2-B266-E7C47ED485F8}
|
{8DD52FAC-ECEE-48C2-B266-E7C47ED485F8} = {8DD52FAC-ECEE-48C2-B266-E7C47ED485F8}
|
||||||
|
{C1FC77E1-04A4-481B-A78B-2F7AF489C2F8} = {C1FC77E1-04A4-481B-A78B-2F7AF489C2F8}
|
||||||
EndProjectSection
|
EndProjectSection
|
||||||
EndProject
|
EndProject
|
||||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "configrpccomponent", "configrpccomponent\configrpccomponent.vcxproj", "{697C6D7E-3109-484C-A7AF-384D28711610}"
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "configrpccomponent", "configrpccomponent\configrpccomponent.vcxproj", "{697C6D7E-3109-484C-A7AF-384D28711610}"
|
||||||
ProjectSection(ProjectDependencies) = postProject
|
ProjectSection(ProjectDependencies) = postProject
|
||||||
|
{66BED474-C33F-48F9-90BA-BBCFEDC006B8} = {66BED474-C33F-48F9-90BA-BBCFEDC006B8}
|
||||||
{9C92DA90-FD53-43A9-A244-90F2E8AF9677} = {9C92DA90-FD53-43A9-A244-90F2E8AF9677}
|
{9C92DA90-FD53-43A9-A244-90F2E8AF9677} = {9C92DA90-FD53-43A9-A244-90F2E8AF9677}
|
||||||
{8DD52FAC-ECEE-48C2-B266-E7C47ED485F8} = {8DD52FAC-ECEE-48C2-B266-E7C47ED485F8}
|
{8DD52FAC-ECEE-48C2-B266-E7C47ED485F8} = {8DD52FAC-ECEE-48C2-B266-E7C47ED485F8}
|
||||||
|
{C1FC77E1-04A4-481B-A78B-2F7AF489C2F8} = {C1FC77E1-04A4-481B-A78B-2F7AF489C2F8}
|
||||||
EndProjectSection
|
EndProjectSection
|
||||||
EndProject
|
EndProject
|
||||||
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "cJSON", "cJSON\cJSON.vcxproj", "{66BED474-C33F-48F9-90BA-BBCFEDC006B8}"
|
||||||
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
Debug|Win32 = Debug|Win32
|
Debug|Win32 = Debug|Win32
|
||||||
|
@ -59,6 +65,10 @@ Global
|
||||||
{697C6D7E-3109-484C-A7AF-384D28711610}.Debug|Win32.Build.0 = Debug|Win32
|
{697C6D7E-3109-484C-A7AF-384D28711610}.Debug|Win32.Build.0 = Debug|Win32
|
||||||
{697C6D7E-3109-484C-A7AF-384D28711610}.Release|Win32.ActiveCfg = Release|Win32
|
{697C6D7E-3109-484C-A7AF-384D28711610}.Release|Win32.ActiveCfg = Release|Win32
|
||||||
{697C6D7E-3109-484C-A7AF-384D28711610}.Release|Win32.Build.0 = Release|Win32
|
{697C6D7E-3109-484C-A7AF-384D28711610}.Release|Win32.Build.0 = Release|Win32
|
||||||
|
{66BED474-C33F-48F9-90BA-BBCFEDC006B8}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||||
|
{66BED474-C33F-48F9-90BA-BBCFEDC006B8}.Debug|Win32.Build.0 = Debug|Win32
|
||||||
|
{66BED474-C33F-48F9-90BA-BBCFEDC006B8}.Release|Win32.ActiveCfg = Release|Win32
|
||||||
|
{66BED474-C33F-48F9-90BA-BBCFEDC006B8}.Release|Win32.Build.0 = Release|Win32
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
|
|
|
@ -5,14 +5,21 @@ bin_PROGRAMS = \
|
||||||
icinga
|
icinga
|
||||||
|
|
||||||
icinga_SOURCES = \
|
icinga_SOURCES = \
|
||||||
connectionmanager.cpp \
|
endpoint.cpp \
|
||||||
connectionmanager.h \
|
endpoint.h \
|
||||||
|
endpointmanager.cpp \
|
||||||
|
endpointmanager.h \
|
||||||
icingaapplication.cpp \
|
icingaapplication.cpp \
|
||||||
icingaapplication.h \
|
icingaapplication.h \
|
||||||
i2-icinga.h
|
i2-icinga.h \
|
||||||
|
jsonrpcendpoint.cpp \
|
||||||
|
jsonrpcendpoint.h \
|
||||||
|
virtualendpoint.cpp \
|
||||||
|
virtualendpoint.h
|
||||||
|
|
||||||
icinga_CXXFLAGS = -I${top_srcdir}/base \
|
icinga_CXXFLAGS = -I${top_srcdir}/base \
|
||||||
-I${top_srcdir}/jsonrpc -I${top_srcdir}
|
-I${top_srcdir}/jsonrpc -I${top_srcdir}
|
||||||
|
|
||||||
icinga_LDFLAGS = $(top_builddir)/jsonrpc/libjsonrpc.la \
|
icinga_LDFLAGS = $(top_builddir)/jsonrpc/libjsonrpc.la \
|
||||||
$(top_builddir)/base/libbase.la
|
$(top_builddir)/base/libbase.la \
|
||||||
|
${top_builddir}/cJSON/libcJSON.la
|
|
@ -1,149 +0,0 @@
|
||||||
#include "i2-icinga.h"
|
|
||||||
|
|
||||||
using namespace icinga;
|
|
||||||
|
|
||||||
void ConnectionManager::SetIdentity(string identity)
|
|
||||||
{
|
|
||||||
m_Identity = identity;
|
|
||||||
}
|
|
||||||
|
|
||||||
string ConnectionManager::GetIdentity(void)
|
|
||||||
{
|
|
||||||
return m_Identity;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ConnectionManager::AddListener(unsigned short port)
|
|
||||||
{
|
|
||||||
JsonRpcServer::Ptr server = make_shared<JsonRpcServer>();
|
|
||||||
RegisterServer(server);
|
|
||||||
|
|
||||||
server->MakeSocket();
|
|
||||||
server->Bind(port);
|
|
||||||
server->Listen();
|
|
||||||
server->Start();
|
|
||||||
}
|
|
||||||
|
|
||||||
void ConnectionManager::AddConnection(string host, short port)
|
|
||||||
{
|
|
||||||
JsonRpcClient::Ptr client = make_shared<JsonRpcClient>();
|
|
||||||
RegisterClient(client);
|
|
||||||
|
|
||||||
client->MakeSocket();
|
|
||||||
client->Connect(host, port);
|
|
||||||
client->Start();
|
|
||||||
}
|
|
||||||
|
|
||||||
void ConnectionManager::RegisterServer(JsonRpcServer::Ptr server)
|
|
||||||
{
|
|
||||||
m_Servers.push_front(server);
|
|
||||||
server->OnNewClient += bind_weak(&ConnectionManager::NewClientHandler, shared_from_this());
|
|
||||||
}
|
|
||||||
|
|
||||||
void ConnectionManager::UnregisterServer(JsonRpcServer::Ptr server)
|
|
||||||
{
|
|
||||||
m_Servers.remove(server);
|
|
||||||
// TODO: unbind event
|
|
||||||
}
|
|
||||||
|
|
||||||
void ConnectionManager::RegisterClient(JsonRpcClient::Ptr client)
|
|
||||||
{
|
|
||||||
m_Clients.push_front(client);
|
|
||||||
client->OnNewMessage += bind_weak(&ConnectionManager::NewMessageHandler, shared_from_this());
|
|
||||||
client->OnClosed += bind_weak(&ConnectionManager::CloseClientHandler, shared_from_this());
|
|
||||||
client->OnError += bind_weak(&ConnectionManager::ErrorClientHandler, shared_from_this());
|
|
||||||
}
|
|
||||||
|
|
||||||
void ConnectionManager::UnregisterClient(JsonRpcClient::Ptr client)
|
|
||||||
{
|
|
||||||
m_Clients.remove(client);
|
|
||||||
// TODO: unbind event
|
|
||||||
}
|
|
||||||
|
|
||||||
int ConnectionManager::NewClientHandler(NewClientEventArgs::Ptr ncea)
|
|
||||||
{
|
|
||||||
JsonRpcClient::Ptr client = static_pointer_cast<JsonRpcClient>(ncea->Client);
|
|
||||||
RegisterClient(client);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int ConnectionManager::CloseClientHandler(EventArgs::Ptr ea)
|
|
||||||
{
|
|
||||||
JsonRpcClient::Ptr client = static_pointer_cast<JsonRpcClient>(ea->Source);
|
|
||||||
UnregisterClient(client);
|
|
||||||
|
|
||||||
if (client->GetPeerHost() != string()) {
|
|
||||||
Timer::Ptr timer = make_shared<Timer>();
|
|
||||||
timer->SetInterval(30);
|
|
||||||
timer->SetUserArgs(ea);
|
|
||||||
timer->OnTimerExpired += bind_weak(&ConnectionManager::ReconnectClientHandler, shared_from_this());
|
|
||||||
timer->Start();
|
|
||||||
m_ReconnectTimers.push_front(timer);
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int ConnectionManager::ErrorClientHandler(SocketErrorEventArgs::Ptr ea)
|
|
||||||
{
|
|
||||||
cout << "Error occured for JSON-RPC socket: Code=" << ea->Code << "; Message=" << ea->Message << endl;
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int ConnectionManager::ReconnectClientHandler(TimerEventArgs::Ptr ea)
|
|
||||||
{
|
|
||||||
JsonRpcClient::Ptr client = static_pointer_cast<JsonRpcClient>(ea->UserArgs->Source);
|
|
||||||
Timer::Ptr timer = static_pointer_cast<Timer>(ea->Source);
|
|
||||||
|
|
||||||
AddConnection(client->GetPeerHost(), client->GetPeerPort());
|
|
||||||
|
|
||||||
timer->Stop();
|
|
||||||
m_ReconnectTimers.remove(timer);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int ConnectionManager::NewMessageHandler(NewMessageEventArgs::Ptr nmea)
|
|
||||||
{
|
|
||||||
JsonRpcMessage::Ptr request = nmea->Message;
|
|
||||||
JsonRpcClient::Ptr client = static_pointer_cast<JsonRpcClient>(nmea->Source);
|
|
||||||
|
|
||||||
map<string, event<NewMessageEventArgs::Ptr> >::iterator i;
|
|
||||||
i = m_Methods.find(request->GetMethod());
|
|
||||||
|
|
||||||
if (i == m_Methods.end()) {
|
|
||||||
JsonRpcMessage::Ptr response = make_shared<JsonRpcMessage>();
|
|
||||||
response->SetVersion("2.0");
|
|
||||||
response->SetError("Unknown method.");
|
|
||||||
response->SetID(request->GetID());
|
|
||||||
Netstring::WriteJSONToFIFO(client->GetSendQueue(), response->GetJSON());
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
i->second(nmea);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ConnectionManager::RegisterMethod(string method, function<int (NewMessageEventArgs::Ptr)> callback)
|
|
||||||
{
|
|
||||||
m_Methods[method] += callback;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ConnectionManager::UnregisterMethod(string method, function<int (NewMessageEventArgs::Ptr)> callback)
|
|
||||||
{
|
|
||||||
// TODO: implement
|
|
||||||
//m_Methods[method] -= callback;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ConnectionManager::SendMessage(JsonRpcMessage::Ptr message)
|
|
||||||
{
|
|
||||||
/* TODO: filter messages based on event subscriptions; also loopback message to our own handlers */
|
|
||||||
for (list<JsonRpcClient::Ptr>::iterator i = m_Clients.begin(); i != m_Clients.end(); i++)
|
|
||||||
{
|
|
||||||
JsonRpcClient::Ptr client = *i;
|
|
||||||
client->SendMessage(message);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -0,0 +1,18 @@
|
||||||
|
#include "i2-icinga.h"
|
||||||
|
|
||||||
|
using namespace icinga;
|
||||||
|
|
||||||
|
Endpoint::Endpoint(void)
|
||||||
|
{
|
||||||
|
m_Connected = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Endpoint::SetConnected(bool connected)
|
||||||
|
{
|
||||||
|
m_Connected = connected;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Endpoint::GetConnected(void)
|
||||||
|
{
|
||||||
|
return m_Connected;
|
||||||
|
}
|
|
@ -0,0 +1,28 @@
|
||||||
|
#ifndef ENDPOINT_H
|
||||||
|
#define ENDPOINT_H
|
||||||
|
|
||||||
|
namespace icinga
|
||||||
|
{
|
||||||
|
|
||||||
|
class EndpointManager;
|
||||||
|
|
||||||
|
class I2_ICINGA_API Endpoint : public Object
|
||||||
|
{
|
||||||
|
private:
|
||||||
|
bool m_Connected;
|
||||||
|
|
||||||
|
public:
|
||||||
|
typedef shared_ptr<Endpoint> Ptr;
|
||||||
|
typedef weak_ptr<Endpoint> WeakPtr;
|
||||||
|
|
||||||
|
Endpoint(void);
|
||||||
|
|
||||||
|
virtual void SetConnected(bool connected);
|
||||||
|
virtual bool GetConnected(void);
|
||||||
|
|
||||||
|
virtual void SendMessage(Endpoint::Ptr source, JsonRpcMessage::Ptr message) = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* ENDPOINT_H */
|
|
@ -0,0 +1,139 @@
|
||||||
|
#include "i2-icinga.h"
|
||||||
|
|
||||||
|
using namespace icinga;
|
||||||
|
|
||||||
|
void EndpointManager::SetIdentity(string identity)
|
||||||
|
{
|
||||||
|
m_Identity = identity;
|
||||||
|
}
|
||||||
|
|
||||||
|
string EndpointManager::GetIdentity(void) const
|
||||||
|
{
|
||||||
|
return m_Identity;
|
||||||
|
}
|
||||||
|
|
||||||
|
void EndpointManager::AddListener(unsigned short port)
|
||||||
|
{
|
||||||
|
JsonRpcServer::Ptr server = make_shared<JsonRpcServer>();
|
||||||
|
RegisterServer(server);
|
||||||
|
|
||||||
|
server->MakeSocket();
|
||||||
|
server->Bind(port);
|
||||||
|
server->Listen();
|
||||||
|
server->Start();
|
||||||
|
}
|
||||||
|
|
||||||
|
void EndpointManager::AddConnection(string host, short port)
|
||||||
|
{
|
||||||
|
JsonRpcClient::Ptr client = make_shared<JsonRpcClient>();
|
||||||
|
RegisterClient(client);
|
||||||
|
|
||||||
|
client->MakeSocket();
|
||||||
|
client->Connect(host, port);
|
||||||
|
client->Start();
|
||||||
|
}
|
||||||
|
|
||||||
|
void EndpointManager::RegisterServer(JsonRpcServer::Ptr server)
|
||||||
|
{
|
||||||
|
m_Servers.push_front(server);
|
||||||
|
server->OnNewClient += bind_weak(&EndpointManager::NewClientHandler, shared_from_this());
|
||||||
|
}
|
||||||
|
|
||||||
|
void EndpointManager::UnregisterServer(JsonRpcServer::Ptr server)
|
||||||
|
{
|
||||||
|
m_Servers.remove(server);
|
||||||
|
// TODO: unbind event
|
||||||
|
}
|
||||||
|
|
||||||
|
void EndpointManager::RegisterClient(JsonRpcClient::Ptr client)
|
||||||
|
{
|
||||||
|
m_Clients.push_front(client);
|
||||||
|
client->OnNewMessage += bind_weak(&EndpointManager::NewMessageHandler, shared_from_this());
|
||||||
|
client->OnClosed += bind_weak(&EndpointManager::CloseClientHandler, shared_from_this());
|
||||||
|
client->OnError += bind_weak(&EndpointManager::ErrorClientHandler, shared_from_this());
|
||||||
|
}
|
||||||
|
|
||||||
|
void EndpointManager::UnregisterClient(JsonRpcClient::Ptr client)
|
||||||
|
{
|
||||||
|
m_Clients.remove(client);
|
||||||
|
// TODO: unbind event
|
||||||
|
}
|
||||||
|
|
||||||
|
int EndpointManager::NewClientHandler(NewClientEventArgs::Ptr ncea)
|
||||||
|
{
|
||||||
|
JsonRpcClient::Ptr client = static_pointer_cast<JsonRpcClient>(ncea->Client);
|
||||||
|
RegisterClient(client);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int EndpointManager::CloseClientHandler(EventArgs::Ptr ea)
|
||||||
|
{
|
||||||
|
JsonRpcClient::Ptr client = static_pointer_cast<JsonRpcClient>(ea->Source);
|
||||||
|
UnregisterClient(client);
|
||||||
|
|
||||||
|
if (client->GetPeerHost() != string()) {
|
||||||
|
Timer::Ptr timer = make_shared<Timer>();
|
||||||
|
timer->SetInterval(30);
|
||||||
|
timer->SetUserArgs(ea);
|
||||||
|
timer->OnTimerExpired += bind_weak(&EndpointManager::ReconnectClientHandler, shared_from_this());
|
||||||
|
timer->Start();
|
||||||
|
m_ReconnectTimers.push_front(timer);
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int EndpointManager::ErrorClientHandler(SocketErrorEventArgs::Ptr ea)
|
||||||
|
{
|
||||||
|
cout << "Error occured for JSON-RPC socket: Code=" << ea->Code << "; Message=" << ea->Message << endl;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int EndpointManager::ReconnectClientHandler(TimerEventArgs::Ptr ea)
|
||||||
|
{
|
||||||
|
JsonRpcClient::Ptr client = static_pointer_cast<JsonRpcClient>(ea->UserArgs->Source);
|
||||||
|
Timer::Ptr timer = static_pointer_cast<Timer>(ea->Source);
|
||||||
|
|
||||||
|
AddConnection(client->GetPeerHost(), client->GetPeerPort());
|
||||||
|
|
||||||
|
timer->Stop();
|
||||||
|
m_ReconnectTimers.remove(timer);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int EndpointManager::NewMessageHandler(NewMessageEventArgs::Ptr nmea)
|
||||||
|
{
|
||||||
|
// TODO: implement
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void EndpointManager::RegisterEndpoint(Endpoint::Ptr endpoint)
|
||||||
|
{
|
||||||
|
m_Endpoints.push_front(endpoint);
|
||||||
|
}
|
||||||
|
|
||||||
|
void EndpointManager::UnregisterEndpoint(Endpoint::Ptr endpoint)
|
||||||
|
{
|
||||||
|
m_Endpoints.remove(endpoint);
|
||||||
|
}
|
||||||
|
|
||||||
|
void EndpointManager::SendMessage(Endpoint::Ptr source, Endpoint::Ptr destination, JsonRpcMessage::Ptr message)
|
||||||
|
{
|
||||||
|
if (destination) {
|
||||||
|
destination->SendMessageA(source, message);
|
||||||
|
} else {
|
||||||
|
for (list<Endpoint::Ptr>::iterator i = m_Endpoints.begin(); i != m_Endpoints.end(); i++)
|
||||||
|
{
|
||||||
|
Endpoint::Ptr endpoint = *i;
|
||||||
|
|
||||||
|
if (endpoint == source)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
endpoint->SendMessage(source, message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,15 +1,15 @@
|
||||||
#ifndef CONNECTIONMANAGER_H
|
#ifndef ENDPOINTMANAGER_H
|
||||||
#define CONNECTIONMANAGER_H
|
#define ENDPOINTMANAGER_H
|
||||||
|
|
||||||
namespace icinga
|
namespace icinga
|
||||||
{
|
{
|
||||||
|
|
||||||
class ConnectionManager : public Object
|
class I2_ICINGA_API EndpointManager : public Object
|
||||||
{
|
{
|
||||||
list<JsonRpcServer::Ptr> m_Servers;
|
list<JsonRpcServer::Ptr> m_Servers;
|
||||||
list<JsonRpcClient::Ptr> m_Clients;
|
list<JsonRpcClient::Ptr> m_Clients;
|
||||||
map< string, event<NewMessageEventArgs::Ptr> > m_Methods;
|
|
||||||
list<Timer::Ptr> m_ReconnectTimers;
|
list<Timer::Ptr> m_ReconnectTimers;
|
||||||
|
list<Endpoint::Ptr> m_Endpoints;
|
||||||
string m_Identity;
|
string m_Identity;
|
||||||
|
|
||||||
int NewClientHandler(NewClientEventArgs::Ptr ncea);
|
int NewClientHandler(NewClientEventArgs::Ptr ncea);
|
||||||
|
@ -23,22 +23,23 @@ class ConnectionManager : public Object
|
||||||
|
|
||||||
void RegisterServer(JsonRpcServer::Ptr server);
|
void RegisterServer(JsonRpcServer::Ptr server);
|
||||||
void UnregisterServer(JsonRpcServer::Ptr server);
|
void UnregisterServer(JsonRpcServer::Ptr server);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
typedef shared_ptr<ConnectionManager> Ptr;
|
typedef shared_ptr<EndpointManager> Ptr;
|
||||||
typedef weak_ptr<ConnectionManager> WeakPtr;
|
typedef weak_ptr<EndpointManager> WeakPtr;
|
||||||
|
|
||||||
void SetIdentity(string identity);
|
void SetIdentity(string identity);
|
||||||
string GetIdentity(void);
|
string GetIdentity(void) const;
|
||||||
|
|
||||||
void AddListener(unsigned short port);
|
void AddListener(unsigned short port);
|
||||||
void AddConnection(string host, short port);
|
void AddConnection(string host, short port);
|
||||||
|
|
||||||
void RegisterMethod(string method, function<int (NewMessageEventArgs::Ptr)> callback);
|
void RegisterEndpoint(Endpoint::Ptr endpoint);
|
||||||
void UnregisterMethod(string method, function<int (NewMessageEventArgs::Ptr)> callback);
|
void UnregisterEndpoint(Endpoint::Ptr endpoint);
|
||||||
|
|
||||||
void SendMessage(JsonRpcMessage::Ptr message);
|
void SendMessage(Endpoint::Ptr source, Endpoint::Ptr destination, JsonRpcMessage::Ptr message);
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* CONNECTIONMANAGER_H */
|
#endif /* ENDPOINTMANAGER_H */
|
|
@ -4,7 +4,16 @@
|
||||||
#include <i2-base.h>
|
#include <i2-base.h>
|
||||||
#include <i2-jsonrpc.h>
|
#include <i2-jsonrpc.h>
|
||||||
|
|
||||||
#include "connectionmanager.h"
|
#ifdef I2_ICINGA_BUILD
|
||||||
|
# define I2_ICINGA_API I2_EXPORT
|
||||||
|
#else /* I2_ICINGA_BUILD */
|
||||||
|
# define I2_ICINGA_API I2_IMPORT
|
||||||
|
#endif /* I2_ICINGA_BUILD */
|
||||||
|
|
||||||
|
#include "endpoint.h"
|
||||||
|
#include "jsonrpcendpoint.h"
|
||||||
|
#include "virtualendpoint.h"
|
||||||
|
#include "endpointmanager.h"
|
||||||
#include "icingaapplication.h"
|
#include "icingaapplication.h"
|
||||||
|
|
||||||
#endif /* I2ICINGA_H */
|
#endif /* I2ICINGA_H */
|
||||||
|
|
|
@ -40,12 +40,12 @@
|
||||||
<PropertyGroup Label="UserMacros" />
|
<PropertyGroup Label="UserMacros" />
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||||
<LinkIncremental>true</LinkIncremental>
|
<LinkIncremental>true</LinkIncremental>
|
||||||
<IncludePath>$(ProjectDir)\..\base;$(ProjectDir)\..\jsonrpc;$(ProjectDir)\..\config;$(IncludePath)</IncludePath>
|
<IncludePath>$(ProjectDir)\..\base;$(ProjectDir)\..\jsonrpc;$(ProjectDir)\..\cJSON;$(IncludePath)</IncludePath>
|
||||||
<LibraryPath>$(OutDir);$(LibraryPath)</LibraryPath>
|
<LibraryPath>$(OutDir);$(LibraryPath)</LibraryPath>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||||
<LinkIncremental>false</LinkIncremental>
|
<LinkIncremental>false</LinkIncremental>
|
||||||
<IncludePath>$(ProjectDir)\..\base;$(ProjectDir)\..\jsonrpc;$(ProjectDir)\..\config;$(IncludePath)</IncludePath>
|
<IncludePath>$(ProjectDir)\..\base;$(ProjectDir)\..\jsonrpc;$(ProjectDir)\..\cJSON;$(IncludePath)</IncludePath>
|
||||||
<LibraryPath>$(OutDir);$(LibraryPath)</LibraryPath>
|
<LibraryPath>$(OutDir);$(LibraryPath)</LibraryPath>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||||
|
@ -59,7 +59,7 @@
|
||||||
<Link>
|
<Link>
|
||||||
<SubSystem>Console</SubSystem>
|
<SubSystem>Console</SubSystem>
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
<AdditionalDependencies>base.lib;jsonrpc.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
<AdditionalDependencies>base.lib;jsonrpc.lib;cJSON.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||||
</Link>
|
</Link>
|
||||||
</ItemDefinitionGroup>
|
</ItemDefinitionGroup>
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||||
|
@ -77,17 +77,23 @@
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||||
<OptimizeReferences>true</OptimizeReferences>
|
<OptimizeReferences>true</OptimizeReferences>
|
||||||
<AdditionalDependencies>base.lib;jsonrpc.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
<AdditionalDependencies>base.lib;jsonrpc.lib;cJSON.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||||
</Link>
|
</Link>
|
||||||
</ItemDefinitionGroup>
|
</ItemDefinitionGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClCompile Include="connectionmanager.cpp" />
|
<ClCompile Include="endpoint.cpp" />
|
||||||
|
<ClCompile Include="endpointmanager.cpp" />
|
||||||
<ClCompile Include="icingaapplication.cpp" />
|
<ClCompile Include="icingaapplication.cpp" />
|
||||||
|
<ClCompile Include="jsonrpcendpoint.cpp" />
|
||||||
|
<ClCompile Include="virtualendpoint.cpp" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClInclude Include="connectionmanager.h" />
|
<ClInclude Include="endpoint.h" />
|
||||||
|
<ClInclude Include="endpointmanager.h" />
|
||||||
<ClInclude Include="icingaapplication.h" />
|
<ClInclude Include="icingaapplication.h" />
|
||||||
<ClInclude Include="i2-icinga.h" />
|
<ClInclude Include="i2-icinga.h" />
|
||||||
|
<ClInclude Include="jsonrpcendpoint.h" />
|
||||||
|
<ClInclude Include="virtualendpoint.h" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||||
<ImportGroup Label="ExtensionTargets">
|
<ImportGroup Label="ExtensionTargets">
|
||||||
|
|
|
@ -11,7 +11,7 @@ using namespace icinga;
|
||||||
|
|
||||||
IcingaApplication::IcingaApplication(void)
|
IcingaApplication::IcingaApplication(void)
|
||||||
{
|
{
|
||||||
m_ConnectionManager = make_shared<ConnectionManager>();
|
m_EndpointManager = make_shared<EndpointManager>();
|
||||||
}
|
}
|
||||||
|
|
||||||
int IcingaApplication::Main(const vector<string>& args)
|
int IcingaApplication::Main(const vector<string>& args)
|
||||||
|
@ -71,9 +71,9 @@ void IcingaApplication::PrintUsage(const string& programPath)
|
||||||
cout << "Syntax: " << programPath << " <config-file>" << endl;
|
cout << "Syntax: " << programPath << " <config-file>" << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
ConnectionManager::Ptr IcingaApplication::GetConnectionManager(void)
|
EndpointManager::Ptr IcingaApplication::GetEndpointManager(void)
|
||||||
{
|
{
|
||||||
return m_ConnectionManager;
|
return m_EndpointManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
int IcingaApplication::NewComponentHandler(ConfigObjectEventArgs::Ptr ea)
|
int IcingaApplication::NewComponentHandler(ConfigObjectEventArgs::Ptr ea)
|
||||||
|
@ -114,7 +114,7 @@ int IcingaApplication::NewRpcListenerHandler(ConfigObjectEventArgs::Ptr ea)
|
||||||
|
|
||||||
Log("Creating JSON-RPC listener on port %d", port);
|
Log("Creating JSON-RPC listener on port %d", port);
|
||||||
|
|
||||||
GetConnectionManager()->AddListener(port);
|
GetEndpointManager()->AddListener(port);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -140,7 +140,7 @@ int IcingaApplication::NewRpcConnectionHandler(ConfigObjectEventArgs::Ptr ea)
|
||||||
|
|
||||||
Log("Creating JSON-RPC connection to %s:%d", hostname.c_str(), port);
|
Log("Creating JSON-RPC connection to %s:%d", hostname.c_str(), port);
|
||||||
|
|
||||||
GetConnectionManager()->AddConnection(hostname, port);
|
GetEndpointManager()->AddConnection(hostname, port);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,10 +4,10 @@
|
||||||
namespace icinga
|
namespace icinga
|
||||||
{
|
{
|
||||||
|
|
||||||
class IcingaApplication : public Application
|
class I2_ICINGA_API IcingaApplication : public Application
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
ConnectionManager::Ptr m_ConnectionManager;
|
EndpointManager::Ptr m_EndpointManager;
|
||||||
|
|
||||||
int NewComponentHandler(ConfigObjectEventArgs::Ptr ea);
|
int NewComponentHandler(ConfigObjectEventArgs::Ptr ea);
|
||||||
int DeletedComponentHandler(ConfigObjectEventArgs::Ptr ea);
|
int DeletedComponentHandler(ConfigObjectEventArgs::Ptr ea);
|
||||||
|
@ -24,11 +24,11 @@ public:
|
||||||
|
|
||||||
IcingaApplication(void);
|
IcingaApplication(void);
|
||||||
|
|
||||||
virtual int Main(const vector<string>& args);
|
int Main(const vector<string>& args);
|
||||||
|
|
||||||
void PrintUsage(const string& programPath);
|
void PrintUsage(const string& programPath);
|
||||||
|
|
||||||
virtual ConnectionManager::Ptr GetConnectionManager(void);
|
EndpointManager::Ptr GetEndpointManager(void);
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,3 @@
|
||||||
|
#include "i2-icinga.h"
|
||||||
|
|
||||||
|
using namespace icinga;
|
|
@ -0,0 +1,14 @@
|
||||||
|
#ifndef JSONRPCENDPOINT_H
|
||||||
|
#define JSONRPCENDPOINT_H
|
||||||
|
|
||||||
|
namespace icinga
|
||||||
|
{
|
||||||
|
|
||||||
|
class I2_ICINGA_API JsonRpcEndpoint : public Endpoint
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* JSONRPCENDPOINT_H */
|
|
@ -0,0 +1,48 @@
|
||||||
|
#include "i2-icinga.h"
|
||||||
|
|
||||||
|
using namespace icinga;
|
||||||
|
|
||||||
|
VirtualEndpoint::VirtualEndpoint()
|
||||||
|
{
|
||||||
|
SetConnected(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
void VirtualEndpoint::RegisterMethodHandler(string method, function<int (NewMessageEventArgs::Ptr)> callback)
|
||||||
|
{
|
||||||
|
m_MethodHandlers[method] += callback;
|
||||||
|
}
|
||||||
|
|
||||||
|
void VirtualEndpoint::UnregisterMethodHandler(string method, function<int (NewMessageEventArgs::Ptr)> callback)
|
||||||
|
{
|
||||||
|
// TODO: implement
|
||||||
|
//m_Methods[method] -= callback;
|
||||||
|
}
|
||||||
|
|
||||||
|
void VirtualEndpoint::RegisterMethodSource(string method)
|
||||||
|
{
|
||||||
|
m_MethodSources.push_front(method);
|
||||||
|
}
|
||||||
|
|
||||||
|
void VirtualEndpoint::UnregisterMethodSource(string method)
|
||||||
|
{
|
||||||
|
m_MethodSources.remove(method);
|
||||||
|
}
|
||||||
|
|
||||||
|
void VirtualEndpoint::SendMessage(Endpoint::Ptr source, JsonRpcMessage::Ptr message)
|
||||||
|
{
|
||||||
|
map<string, event<NewMessageEventArgs::Ptr> >::iterator i;
|
||||||
|
i = m_MethodHandlers.find(message->GetMethod());
|
||||||
|
|
||||||
|
if (i == m_MethodHandlers.end()) {
|
||||||
|
JsonRpcMessage::Ptr response = make_shared<JsonRpcMessage>();
|
||||||
|
response->SetVersion("2.0");
|
||||||
|
response->SetError("Unknown method.");
|
||||||
|
response->SetID(message->GetID());
|
||||||
|
source->SendMessage(static_pointer_cast<Endpoint>(shared_from_this()), response);
|
||||||
|
}
|
||||||
|
|
||||||
|
NewMessageEventArgs::Ptr nmea = make_shared<NewMessageEventArgs>();
|
||||||
|
nmea->Source = shared_from_this();
|
||||||
|
nmea->Message = message;
|
||||||
|
i->second(nmea);
|
||||||
|
}
|
|
@ -0,0 +1,30 @@
|
||||||
|
#ifndef VIRTUALENDPOINT_H
|
||||||
|
#define VIRTUALENDPOINT_H
|
||||||
|
|
||||||
|
namespace icinga
|
||||||
|
{
|
||||||
|
|
||||||
|
class I2_ICINGA_API VirtualEndpoint : public Endpoint
|
||||||
|
{
|
||||||
|
private:
|
||||||
|
map< string, event<NewMessageEventArgs::Ptr> > m_MethodHandlers;
|
||||||
|
list<string> m_MethodSources;
|
||||||
|
|
||||||
|
public:
|
||||||
|
typedef shared_ptr<VirtualEndpoint> Ptr;
|
||||||
|
typedef weak_ptr<VirtualEndpoint> WeakPtr;
|
||||||
|
|
||||||
|
VirtualEndpoint();
|
||||||
|
|
||||||
|
virtual void RegisterMethodHandler(string method, function<int (NewMessageEventArgs::Ptr)> callback);
|
||||||
|
virtual void UnregisterMethodHandler(string method, function<int (NewMessageEventArgs::Ptr)> callback);
|
||||||
|
|
||||||
|
virtual void RegisterMethodSource(string method);
|
||||||
|
virtual void UnregisterMethodSource(string method);
|
||||||
|
|
||||||
|
virtual void SendMessage(Endpoint::Ptr source, JsonRpcMessage::Ptr message);
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* VIRTUALENDPOINT_H */
|
|
@ -5,8 +5,6 @@ noinst_LTLIBRARIES = \
|
||||||
libjsonrpc.la
|
libjsonrpc.la
|
||||||
|
|
||||||
libjsonrpc_la_SOURCES = \
|
libjsonrpc_la_SOURCES = \
|
||||||
cJSON.c \
|
|
||||||
cJSON.h \
|
|
||||||
i2-jsonrpc.h \
|
i2-jsonrpc.h \
|
||||||
jsonrpcclient.cpp \
|
jsonrpcclient.cpp \
|
||||||
jsonrpcclient.h \
|
jsonrpcclient.h \
|
||||||
|
|
|
@ -3,8 +3,14 @@
|
||||||
|
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <i2-base.h>
|
#include <i2-base.h>
|
||||||
|
#include <cJSON.h>
|
||||||
|
|
||||||
|
#ifdef I2_JSONRPC_BUILD
|
||||||
|
# define I2_JSONRPC_API I2_EXPORT
|
||||||
|
#else /* I2_JSONRPC_BUILD */
|
||||||
|
# define I2_JSONRPC_API I2_IMPORT
|
||||||
|
#endif /* I2_JSONRPC_BUILD */
|
||||||
|
|
||||||
#include "cJSON.h"
|
|
||||||
#include "netstring.h"
|
#include "netstring.h"
|
||||||
#include "jsonrpcmessage.h"
|
#include "jsonrpcmessage.h"
|
||||||
#include "jsonrpcclient.h"
|
#include "jsonrpcclient.h"
|
||||||
|
|
|
@ -11,7 +11,6 @@
|
||||||
</ProjectConfiguration>
|
</ProjectConfiguration>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClInclude Include="cJSON.h" />
|
|
||||||
<ClInclude Include="i2-jsonrpc.h" />
|
<ClInclude Include="i2-jsonrpc.h" />
|
||||||
<ClInclude Include="jsonrpcclient.h" />
|
<ClInclude Include="jsonrpcclient.h" />
|
||||||
<ClInclude Include="jsonrpcmessage.h" />
|
<ClInclude Include="jsonrpcmessage.h" />
|
||||||
|
@ -19,7 +18,6 @@
|
||||||
<ClInclude Include="netstring.h" />
|
<ClInclude Include="netstring.h" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClCompile Include="cJSON.c" />
|
|
||||||
<ClCompile Include="jsonrpcclient.cpp" />
|
<ClCompile Include="jsonrpcclient.cpp" />
|
||||||
<ClCompile Include="jsonrpcmessage.cpp" />
|
<ClCompile Include="jsonrpcmessage.cpp" />
|
||||||
<ClCompile Include="jsonrpcserver.cpp" />
|
<ClCompile Include="jsonrpcserver.cpp" />
|
||||||
|
@ -32,12 +30,12 @@
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||||
<UseDebugLibraries>true</UseDebugLibraries>
|
<UseDebugLibraries>true</UseDebugLibraries>
|
||||||
<CharacterSet>MultiByte</CharacterSet>
|
<CharacterSet>MultiByte</CharacterSet>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||||
<UseDebugLibraries>false</UseDebugLibraries>
|
<UseDebugLibraries>false</UseDebugLibraries>
|
||||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||||
<CharacterSet>MultiByte</CharacterSet>
|
<CharacterSet>MultiByte</CharacterSet>
|
||||||
|
@ -53,11 +51,11 @@
|
||||||
</ImportGroup>
|
</ImportGroup>
|
||||||
<PropertyGroup Label="UserMacros" />
|
<PropertyGroup Label="UserMacros" />
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||||
<IncludePath>$(ProjectDir)\..\base;$(IncludePath)</IncludePath>
|
<IncludePath>$(ProjectDir)\..\base;$(ProjectDir)\..\cJSON;$(IncludePath)</IncludePath>
|
||||||
<LibraryPath>$(OutDir);$(LibraryPath)</LibraryPath>
|
<LibraryPath>$(OutDir);$(LibraryPath)</LibraryPath>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||||
<IncludePath>$(ProjectDir)\..\base;$(IncludePath)</IncludePath>
|
<IncludePath>$(ProjectDir)\..\base;$(ProjectDir)\..\cJSON;$(IncludePath)</IncludePath>
|
||||||
<LibraryPath>$(OutDir);$(LibraryPath)</LibraryPath>
|
<LibraryPath>$(OutDir);$(LibraryPath)</LibraryPath>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||||
|
@ -66,11 +64,12 @@
|
||||||
</PrecompiledHeader>
|
</PrecompiledHeader>
|
||||||
<WarningLevel>Level3</WarningLevel>
|
<WarningLevel>Level3</WarningLevel>
|
||||||
<Optimization>Disabled</Optimization>
|
<Optimization>Disabled</Optimization>
|
||||||
<PreprocessorDefinitions>WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
<PreprocessorDefinitions>WIN32;I2_JSONRPC_BUILD;_DEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<SubSystem>Windows</SubSystem>
|
<SubSystem>Windows</SubSystem>
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
|
<AdditionalDependencies>base.lib;cJSON.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||||
</Link>
|
</Link>
|
||||||
<Lib>
|
<Lib>
|
||||||
<AdditionalDependencies>
|
<AdditionalDependencies>
|
||||||
|
@ -85,13 +84,14 @@
|
||||||
<Optimization>MaxSpeed</Optimization>
|
<Optimization>MaxSpeed</Optimization>
|
||||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||||
<PreprocessorDefinitions>WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
<PreprocessorDefinitions>WIN32;I2_JSONRPC_BUILD;NDEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<SubSystem>Windows</SubSystem>
|
<SubSystem>Windows</SubSystem>
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||||
<OptimizeReferences>true</OptimizeReferences>
|
<OptimizeReferences>true</OptimizeReferences>
|
||||||
|
<AdditionalDependencies>base.lib;cJSON.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||||
</Link>
|
</Link>
|
||||||
<Lib>
|
<Lib>
|
||||||
<AdditionalDependencies>
|
<AdditionalDependencies>
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
namespace icinga
|
namespace icinga
|
||||||
{
|
{
|
||||||
|
|
||||||
struct NewMessageEventArgs : public EventArgs
|
struct I2_JSONRPC_API NewMessageEventArgs : public EventArgs
|
||||||
{
|
{
|
||||||
typedef shared_ptr<NewMessageEventArgs> Ptr;
|
typedef shared_ptr<NewMessageEventArgs> Ptr;
|
||||||
typedef weak_ptr<NewMessageEventArgs> WeakPtr;
|
typedef weak_ptr<NewMessageEventArgs> WeakPtr;
|
||||||
|
@ -12,7 +12,7 @@ struct NewMessageEventArgs : public EventArgs
|
||||||
JsonRpcMessage::Ptr Message;
|
JsonRpcMessage::Ptr Message;
|
||||||
};
|
};
|
||||||
|
|
||||||
class JsonRpcClient : public TCPClient
|
class I2_JSONRPC_API JsonRpcClient : public TCPClient
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
int DataAvailableHandler(EventArgs::Ptr ea);
|
int DataAvailableHandler(EventArgs::Ptr ea);
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
namespace icinga
|
namespace icinga
|
||||||
{
|
{
|
||||||
|
|
||||||
class JsonRpcMessage : public Object
|
class I2_JSONRPC_API JsonRpcMessage : public Object
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
cJSON *m_JSON;
|
cJSON *m_JSON;
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
namespace icinga
|
namespace icinga
|
||||||
{
|
{
|
||||||
|
|
||||||
class JsonRpcServer : public TCPServer
|
class I2_JSONRPC_API JsonRpcServer : public TCPServer
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
typedef shared_ptr<JsonRpcServer> Ptr;
|
typedef shared_ptr<JsonRpcServer> Ptr;
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
namespace icinga
|
namespace icinga
|
||||||
{
|
{
|
||||||
|
|
||||||
class Netstring : public Object
|
class I2_JSONRPC_API Netstring : public Object
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
size_t m_Length;
|
size_t m_Length;
|
||||||
|
|
Loading…
Reference in New Issue