diff --git a/base/application.cpp b/base/application.cpp
index 0e724197a..88c12a372 100644
--- a/base/application.cpp
+++ b/base/application.cpp
@@ -159,9 +159,6 @@ void Application::RunEventLoop(void)
else if (ready == 0)
continue;
- EventArgs ea;
- ea.Source = shared_from_this();
-
for (i = Socket::Sockets.begin();
i != Socket::Sockets.end(); ) {
Socket::Ptr socket = i->lock();
@@ -178,15 +175,15 @@ void Application::RunEventLoop(void)
fd = socket->GetFD();
if (fd != INVALID_SOCKET && FD_ISSET(fd, &writefds))
- socket->OnWritable(ea);
+ socket->OnWritable(socket);
fd = socket->GetFD();
if (fd != INVALID_SOCKET && FD_ISSET(fd, &readfds))
- socket->OnReadable(ea);
+ socket->OnReadable(socket);
fd = socket->GetFD();
if (fd != INVALID_SOCKET && FD_ISSET(fd, &exceptfds))
- socket->OnException(ea);
+ socket->OnException(socket);
}
}
}
diff --git a/base/base.vcxproj b/base/base.vcxproj
index fd5a13cf4..651193e83 100644
--- a/base/base.vcxproj
+++ b/base/base.vcxproj
@@ -36,7 +36,6 @@
-
diff --git a/base/eventargs.h b/base/eventargs.h
deleted file mode 100644
index f913b7e8d..000000000
--- a/base/eventargs.h
+++ /dev/null
@@ -1,38 +0,0 @@
-/******************************************************************************
- * Icinga 2 *
- * Copyright (C) 2012 Icinga Development Team (http://www.icinga.org/) *
- * *
- * This program is free software; you can redistribute it and/or *
- * modify it under the terms of the GNU General Public License *
- * as published by the Free Software Foundation; either version 2 *
- * of the License, or (at your option) any later version. *
- * *
- * This program is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
- * *
- * You should have received a copy of the GNU General Public License *
- * along with this program; if not, write to the Free Software Foundation *
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. *
- ******************************************************************************/
-
-#ifndef EVENTARGS_H
-#define EVENTARGS_H
-
-namespace icinga
-{
-
-/**
- * Base class for event arguments.
- *
- * @ingroup base
- */
-struct I2_BASE_API EventArgs
-{
- Object::Ptr Source; /**< The source of the event. */
-};
-
-}
-
-#endif /* EVENTARGS_H */
diff --git a/base/i2-base.h b/base/i2-base.h
index af524ef7c..63141d166 100644
--- a/base/i2-base.h
+++ b/base/i2-base.h
@@ -145,7 +145,6 @@ using boost::function;
#include "exception.h"
#include "memory.h"
#include "variant.h"
-#include "eventargs.h"
#include "dictionary.h"
#include "timer.h"
#include "fifo.h"
diff --git a/base/objectmap.h b/base/objectmap.h
index 0fb42f55d..9a6cc04b0 100644
--- a/base/objectmap.h
+++ b/base/objectmap.h
@@ -43,9 +43,9 @@ public:
void Start(void)
{
- m_Parent->OnObjectAdded.connect(boost::bind(&ObjectMap::ObjectAddedHandler, this, _1));
- m_Parent->OnObjectCommitted.connect(boost::bind(&ObjectMap::ObjectCommittedHandler, this, _1));
- m_Parent->OnObjectRemoved.connect(boost::bind(&ObjectMap::ObjectRemovedHandler, this, _1));
+ m_Parent->OnObjectAdded.connect(boost::bind(&ObjectMap::ObjectAddedHandler, this, _2));
+ m_Parent->OnObjectCommitted.connect(boost::bind(&ObjectMap::ObjectCommittedHandler, this, _2));
+ m_Parent->OnObjectRemoved.connect(boost::bind(&ObjectMap::ObjectRemovedHandler, this, _2));
for (typename ObjectSet::Iterator it = m_Parent->Begin(); it != m_Parent->End(); it++)
AddObject(*it);
@@ -56,16 +56,12 @@ public:
return m_Objects.equal_range(key);
}
- void ForeachObject(TKey key, function&)> callback)
+ void ForeachObject(TKey key, function::Ptr, const TValue&)> callback)
{
- ObjectSetEventArgs ea;
- ea.Source = shared_from_this();
-
Range range = GetRange(key);
for (Iterator it = range.first; it != range.second; it++) {
- ea.Target(*it);
- callback(ea);
+ callback(shared_from_this(), *it);
}
}
@@ -105,19 +101,19 @@ private:
AddObject(object);
}
- void ObjectAddedHandler(const ObjectSetEventArgs& ea)
+ void ObjectAddedHandler(const TValue& object)
{
- AddObject(ea.Target);
+ AddObject(object);
}
- void ObjectCommittedHandler(const ObjectSetEventArgs& ea)
+ void ObjectCommittedHandler(const TValue& object)
{
- CheckObject(ea.Target);
+ CheckObject(object);
}
- void ObjectRemovedHandler(const ObjectSetEventArgs& ea)
+ void ObjectRemovedHandler(const TValue& object)
{
- RemoveObject(ea.Target);
+ RemoveObject(object);
}
};
diff --git a/base/objectset.h b/base/objectset.h
index 692723e8c..394045610 100644
--- a/base/objectset.h
+++ b/base/objectset.h
@@ -23,12 +23,6 @@
namespace icinga
{
-template
-struct ObjectSetEventArgs : public EventArgs
-{
- TValue Target;
-};
-
template
class ObjectSet : public Object
{
@@ -49,25 +43,19 @@ public:
void Start(void)
{
if (m_Parent) {
- m_Parent->OnObjectAdded.connect(boost::bind(&ObjectSet::ObjectAddedOrCommittedHandler, this, _1));
- m_Parent->OnObjectCommitted.connect(boost::bind(&ObjectSet::ObjectAddedOrCommittedHandler, this, _1));
- m_Parent->OnObjectRemoved.connect(boost::bind(&ObjectSet::ObjectRemovedHandler, this, _1));
+ m_Parent->OnObjectAdded.connect(boost::bind(&ObjectSet::ObjectAddedOrCommittedHandler, this, _2));
+ m_Parent->OnObjectCommitted.connect(boost::bind(&ObjectSet::ObjectAddedOrCommittedHandler, this, _2));
+ m_Parent->OnObjectRemoved.connect(boost::bind(&ObjectSet::ObjectRemovedHandler, this, _2));
for (ObjectSet::Iterator it = m_Parent->Begin(); it != m_Parent->End(); it++)
CheckObject(*it);
- }
-
-
+ }
}
void AddObject(const TValue& object)
{
m_Objects.insert(object);
-
- ObjectSetEventArgs ea;
- ea.Source = shared_from_this();
- ea.Target = object;
- OnObjectAdded(ea);
+ OnObjectAdded(shared_from_this(), object);
}
void RemoveObject(const TValue& object)
@@ -76,11 +64,7 @@ public:
if (it != m_Objects.end()) {
m_Objects.erase(it);
-
- ObjectSetEventArgs ea;
- ea.Source = shared_from_this();
- ea.Target = object;
- OnObjectRemoved(ea);
+ OnObjectRemoved(shared_from_this(), object);
}
}
@@ -97,17 +81,14 @@ public:
if (!Contains(object)) {
AddObject(object);
} else {
- ObjectSetEventArgs ea;
- ea.Source = shared_from_this();
- ea.Target = object;
- OnObjectCommitted(ea);
+ OnObjectCommitted(shared_from_this(), object);
}
}
}
- boost::signal&)> OnObjectAdded;
- boost::signal&)> OnObjectCommitted;
- boost::signal&)> OnObjectRemoved;
+ boost::signal OnObjectAdded;
+ boost::signal OnObjectCommitted;
+ boost::signal OnObjectRemoved;
Iterator Begin(void)
{
@@ -119,14 +100,10 @@ public:
return m_Objects.end();
}
- void ForeachObject(function&)> callback)
+ void ForeachObject(function callback)
{
- ObjectSetEventArgs ea;
- ea.Source = shared_from_this();
-
for (Iterator it = Begin(); it != End(); it++) {
- ea.Target(*it);
- callback(ea);
+ callback(shared_from_this(), *it);
}
}
@@ -136,14 +113,14 @@ private:
typename ObjectSet::Ptr m_Parent;
function m_Predicate;
- void ObjectAddedOrCommittedHandler(const ObjectSetEventArgs& ea)
+ void ObjectAddedOrCommittedHandler(const TValue& object)
{
- CheckObject(ea.Target);
+ CheckObject(object);
}
- void ObjectRemovedHandler(const ObjectSetEventArgs& ea)
+ void ObjectRemovedHandler(const TValue& object)
{
- RemoveObject(ea.Target);
+ RemoveObject(object);
}
};
diff --git a/base/socket.cpp b/base/socket.cpp
index 570c0363e..6701342dd 100644
--- a/base/socket.cpp
+++ b/base/socket.cpp
@@ -50,7 +50,7 @@ void Socket::Start(void)
{
assert(m_FD != INVALID_SOCKET);
- OnException.connect(boost::bind(&Socket::ExceptionEventHandler, this, _1));
+ OnException.connect(boost::bind(&Socket::ExceptionEventHandler, this));
Sockets.push_back(static_pointer_cast(shared_from_this()));
}
@@ -125,9 +125,7 @@ void Socket::CloseInternal(bool from_dtor)
if (!from_dtor) {
Stop();
- EventArgs ea;
- ea.Source = shared_from_this();
- OnClosed(ea);
+ OnClosed(shared_from_this());
}
}
@@ -172,8 +170,7 @@ int Socket::GetLastSocketError(void)
void Socket::HandleSocketError(const std::exception& ex)
{
if (!OnError.empty()) {
- SocketErrorEventArgs sea(ex);
- OnError(sea);
+ OnError(shared_from_this(), ex);
Close();
} else {
@@ -186,7 +183,7 @@ void Socket::HandleSocketError(const std::exception& ex)
*
* @param - Event arguments for the socket error.
*/
-void Socket::ExceptionEventHandler(const EventArgs&)
+void Socket::ExceptionEventHandler(void)
{
HandleSocketError(SocketException(
"select() returned fd in except fdset", GetError()));
diff --git a/base/socket.h b/base/socket.h
index feb8a2c58..0fe6316f2 100644
--- a/base/socket.h
+++ b/base/socket.h
@@ -22,19 +22,6 @@
namespace icinga {
-/**
- * Event arguments for socket errors.
- *
- * @ingroup base
- */
-struct I2_BASE_API SocketErrorEventArgs : public EventArgs
-{
- const std::exception& Exception;
-
- SocketErrorEventArgs(const std::exception& ex)
- : Exception(ex) { }
-};
-
/**
* Base class for sockets.
*
@@ -55,12 +42,12 @@ public:
void SetFD(SOCKET fd);
SOCKET GetFD(void) const;
- boost::signal OnReadable;
- boost::signal OnWritable;
- boost::signal OnException;
+ boost::signal OnReadable;
+ boost::signal OnWritable;
+ boost::signal OnException;
- boost::signal OnError;
- boost::signal OnClosed;
+ boost::signal OnError;
+ boost::signal OnClosed;
virtual bool WantsToRead(void) const;
virtual bool WantsToWrite(void) const;
@@ -85,7 +72,7 @@ protected:
private:
SOCKET m_FD; /**< The socket descriptor. */
- void ExceptionEventHandler(const EventArgs& ea);
+ void ExceptionEventHandler(void);
static string GetAddressFromSockaddr(sockaddr *address, socklen_t len);
};
diff --git a/base/tcpclient.cpp b/base/tcpclient.cpp
index 4b5e07113..1363ef308 100644
--- a/base/tcpclient.cpp
+++ b/base/tcpclient.cpp
@@ -51,8 +51,8 @@ void TcpClient::Start(void)
{
TcpSocket::Start();
- OnReadable.connect(boost::bind(&TcpClient::ReadableEventHandler, this, _1));
- OnWritable.connect(boost::bind(&TcpClient::WritableEventHandler, this, _1));
+ OnReadable.connect(boost::bind(&TcpClient::ReadableEventHandler, this));
+ OnWritable.connect(boost::bind(&TcpClient::WritableEventHandler, this));
}
/**
@@ -136,10 +136,8 @@ FIFO::Ptr TcpClient::GetRecvQueue(void)
/**
* Processes data that is available for this socket.
- *
- * @param - Event arguments.
*/
-void TcpClient::ReadableEventHandler(const EventArgs&)
+void TcpClient::ReadableEventHandler(void)
{
int rc;
@@ -161,17 +159,13 @@ void TcpClient::ReadableEventHandler(const EventArgs&)
m_RecvQueue->Write(NULL, rc);
- EventArgs dea;
- dea.Source = shared_from_this();
- OnDataAvailable(dea);
+ OnDataAvailable(shared_from_this());
}
/**
* Processes data that can be written for this socket.
- *
- * @param - Event arguments.
*/
-void TcpClient::WritableEventHandler(const EventArgs&)
+void TcpClient::WritableEventHandler(void)
{
int rc;
diff --git a/base/tcpclient.h b/base/tcpclient.h
index 5f2d553cb..2afd01942 100644
--- a/base/tcpclient.h
+++ b/base/tcpclient.h
@@ -61,7 +61,7 @@ public:
virtual bool WantsToRead(void) const;
virtual bool WantsToWrite(void) const;
- boost::signal OnDataAvailable;
+ boost::signal OnDataAvailable;
private:
TcpClientRole m_Role;
@@ -69,8 +69,8 @@ private:
FIFO::Ptr m_SendQueue;
FIFO::Ptr m_RecvQueue;
- virtual void ReadableEventHandler(const EventArgs& ea);
- virtual void WritableEventHandler(const EventArgs& ea);
+ virtual void ReadableEventHandler(void);
+ virtual void WritableEventHandler(void);
};
/**
diff --git a/base/tcpserver.cpp b/base/tcpserver.cpp
index e50343ff4..876bb9168 100644
--- a/base/tcpserver.cpp
+++ b/base/tcpserver.cpp
@@ -56,7 +56,7 @@ void TcpServer::Start(void)
{
TcpSocket::Start();
- OnReadable.connect(boost::bind(&TcpServer::ReadableEventHandler, this, _1));
+ OnReadable.connect(boost::bind(&TcpServer::ReadableEventHandler, this));
}
/**
@@ -64,9 +64,7 @@ void TcpServer::Start(void)
*/
void TcpServer::Listen(void)
{
- int rc = listen(GetFD(), SOMAXCONN);
-
- if (rc < 0) {
+ if (listen(GetFD(), SOMAXCONN) < 0) {
HandleSocketError(SocketException(
"listen() failed", GetError()));
return;
@@ -76,11 +74,8 @@ void TcpServer::Listen(void)
/**
* Accepts a new client and creates a new client object for it
* using the client factory function.
- *
- * @param - Event arguments.
- * @returns 0
*/
-int TcpServer::ReadableEventHandler(const EventArgs&)
+void TcpServer::ReadableEventHandler(void)
{
int fd;
sockaddr_storage addr;
@@ -91,17 +86,14 @@ int TcpServer::ReadableEventHandler(const EventArgs&)
if (fd < 0) {
HandleSocketError(SocketException(
"accept() failed", GetError()));
- return 0;
+ return;
}
- NewClientEventArgs nea;
- nea.Source = shared_from_this();
- nea.Client = static_pointer_cast(m_ClientFactory());
- nea.Client->SetFD(fd);
- nea.Client->Start();
- OnNewClient(nea);
+ TcpClient::Ptr client = m_ClientFactory();
+ client->SetFD(fd);
+ client->Start();
- return 0;
+ OnNewClient(shared_from_this(), client);
}
/**
diff --git a/base/tcpserver.h b/base/tcpserver.h
index 260effcd4..62b59d65f 100644
--- a/base/tcpserver.h
+++ b/base/tcpserver.h
@@ -23,16 +23,6 @@
namespace icinga
{
-/**
- * Event arguments for the "new client" event.
- *
- * @ingroup base
- */
-struct I2_BASE_API NewClientEventArgs : public EventArgs
-{
- TcpSocket::Ptr Client; /**< The new client object. */
-};
-
/**
* A TCP server that listens on a TCP port and accepts incoming
* client connections.
@@ -54,12 +44,12 @@ public:
void Listen(void);
- boost::signal OnNewClient;
+ boost::signal OnNewClient;
virtual bool WantsToRead(void) const;
private:
- int ReadableEventHandler(const EventArgs& ea);
+ void ReadableEventHandler(void);
function m_ClientFactory;
};
diff --git a/base/timer.cpp b/base/timer.cpp
index bf212786e..9d404af34 100644
--- a/base/timer.cpp
+++ b/base/timer.cpp
@@ -100,9 +100,7 @@ void Timer::CallExpiredTimers(void)
*/
void Timer::Call(void)
{
- EventArgs tea;
- tea.Source = shared_from_this();
- OnTimerExpired(tea);
+ OnTimerExpired(shared_from_this());
}
/**
diff --git a/base/timer.h b/base/timer.h
index 5f119e11a..c9ea4db0b 100644
--- a/base/timer.h
+++ b/base/timer.h
@@ -52,7 +52,7 @@ public:
void Reschedule(time_t next);
- boost::signal OnTimerExpired;
+ boost::signal OnTimerExpired;
private:
time_t m_Interval; /**< The interval of the timer. */
diff --git a/base/tlsclient.cpp b/base/tlsclient.cpp
index 886b5ea6c..065730745 100644
--- a/base/tlsclient.cpp
+++ b/base/tlsclient.cpp
@@ -105,10 +105,8 @@ void TlsClient::Start(void)
/**
* Processes data that is available for this socket.
- *
- * @param - Event arguments.
*/
-void TlsClient::ReadableEventHandler(const EventArgs&)
+void TlsClient::ReadableEventHandler(void)
{
int rc;
@@ -138,17 +136,13 @@ void TlsClient::ReadableEventHandler(const EventArgs&)
GetRecvQueue()->Write(NULL, rc);
- EventArgs dea;
- dea.Source = shared_from_this();
- OnDataAvailable(dea);
+ OnDataAvailable(shared_from_this());
}
/**
* Processes data that can be written for this socket.
- *
- * @param - Event arguments.
*/
-void TlsClient::WritableEventHandler(const EventArgs&)
+void TlsClient::WritableEventHandler(void)
{
int rc;
@@ -248,12 +242,9 @@ int TlsClient::SSLVerifyCertificate(int ok, X509_STORE_CTX *x509Context)
if (client == NULL)
return 0;
- VerifyCertificateEventArgs vcea;
- vcea.Source = client->shared_from_this();
- vcea.ValidCertificate = (ok != 0);
- vcea.Context = x509Context;
- vcea.Certificate = shared_ptr(x509Context->cert, &TlsClient::NullCertificateDeleter);
- client->OnVerifyCertificate(vcea);
+ bool valid = false;
+ shared_ptr x509Certificate = shared_ptr(x509Context->cert, &TlsClient::NullCertificateDeleter);
+ client->OnVerifyCertificate(client->shared_from_this(), valid, x509Context, x509Certificate);
- return (int)vcea.ValidCertificate;
+ return valid ? 1 : 0;
}
diff --git a/base/tlsclient.h b/base/tlsclient.h
index 2773c0c96..0968fbff0 100644
--- a/base/tlsclient.h
+++ b/base/tlsclient.h
@@ -23,20 +23,6 @@
namespace icinga
{
-/**
- * Event arguments for the "SSL certificate verification" event.
- *
- * @ingroup base
- */
-struct I2_BASE_API VerifyCertificateEventArgs : public EventArgs
-{
- bool ValidCertificate; /**< Whether the certificate is valid, can be
- changed by the event handler. */
- X509_STORE_CTX *Context; /**< The X509 store context. */
- shared_ptr Certificate; /**< The X509 certificate that should
- ve verified. */
-};
-
/**
* A TLS client connection.
*
@@ -55,7 +41,7 @@ public:
virtual bool WantsToRead(void) const;
virtual bool WantsToWrite(void) const;
- boost::signal OnVerifyCertificate;
+ boost::signal&)> OnVerifyCertificate;
protected:
void HandleSSLError(void);
@@ -70,8 +56,8 @@ private:
static int m_SSLIndex;
static bool m_SSLIndexInitialized;
- virtual void ReadableEventHandler(const EventArgs& ea);
- virtual void WritableEventHandler(const EventArgs& ea);
+ virtual void ReadableEventHandler(void);
+ virtual void WritableEventHandler(void);
virtual void CloseInternal(bool from_dtor);
diff --git a/components/checker/checker.vcxproj.filters b/components/checker/checker.vcxproj.filters
new file mode 100644
index 000000000..7e4bd0630
--- /dev/null
+++ b/components/checker/checker.vcxproj.filters
@@ -0,0 +1,26 @@
+
+
+
+
+ {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
+ cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
+
+
+ {93995380-89BD-4b04-88EB-625FBE52EBFB}
+ h;hpp;hxx;hm;inl;inc;xsd
+
+
+
+
+ Headerdateien
+
+
+ Headerdateien
+
+
+
+
+ Quelldateien
+
+
+
\ No newline at end of file
diff --git a/components/checker/checkercomponent.cpp b/components/checker/checkercomponent.cpp
index 79ef54ae8..97b8f4883 100644
--- a/components/checker/checkercomponent.cpp
+++ b/components/checker/checkercomponent.cpp
@@ -30,11 +30,11 @@ void CheckerComponent::Start(void)
{
m_CheckerEndpoint = boost::make_shared();
m_CheckerEndpoint->RegisterTopicHandler("checker::AssignService",
- boost::bind(&CheckerComponent::AssignServiceRequestHandler, this, _1));
+ boost::bind(&CheckerComponent::AssignServiceRequestHandler, this, _2, _3));
m_CheckerEndpoint->RegisterTopicHandler("checker::RevokeService",
- boost::bind(&CheckerComponent::RevokeServiceRequestHandler, this, _1));
+ boost::bind(&CheckerComponent::RevokeServiceRequestHandler, this, _2, _3));
m_CheckerEndpoint->RegisterTopicHandler("checker::ClearServices",
- boost::bind(&CheckerComponent::ClearServicesRequestHandler, this, _1));
+ boost::bind(&CheckerComponent::ClearServicesRequestHandler, this, _2, _3));
m_CheckerEndpoint->RegisterPublication("checker::CheckResult");
GetEndpointManager()->RegisterEndpoint(m_CheckerEndpoint);
@@ -90,10 +90,10 @@ void CheckerComponent::CheckTimerHandler(void)
m_CheckTimer->SetInterval(service.GetNextCheck() - now);
}
-void CheckerComponent::AssignServiceRequestHandler(const NewRequestEventArgs& nrea)
+void CheckerComponent::AssignServiceRequestHandler(const Endpoint::Ptr& sender, const RequestMessage& request)
{
MessagePart params;
- if (!nrea.Request.GetParams(¶ms))
+ if (!request.GetParams(¶ms))
return;
MessagePart serviceMsg;
@@ -110,20 +110,20 @@ void CheckerComponent::AssignServiceRequestHandler(const NewRequestEventArgs& nr
m_CheckTimer->Reschedule(0);
string id;
- if (nrea.Request.GetID(&id)) {
+ if (request.GetID(&id)) {
ResponseMessage rm;
rm.SetID(id);
MessagePart result;
rm.SetResult(result);
- GetEndpointManager()->SendUnicastMessage(m_CheckerEndpoint, nrea.Sender, rm);
+ GetEndpointManager()->SendUnicastMessage(m_CheckerEndpoint, sender, rm);
}
}
-void CheckerComponent::RevokeServiceRequestHandler(const NewRequestEventArgs& nrea)
+void CheckerComponent::RevokeServiceRequestHandler(const Endpoint::Ptr& sender, const RequestMessage& request)
{
MessagePart params;
- if (!nrea.Request.GetParams(¶ms))
+ if (!request.GetParams(¶ms))
return;
string name;
@@ -148,29 +148,29 @@ void CheckerComponent::RevokeServiceRequestHandler(const NewRequestEventArgs& nr
Application::Log(LogInformation, "checker", "Revoked delegation for service '" + name + "'");
string id;
- if (nrea.Request.GetID(&id)) {
+ if (request.GetID(&id)) {
ResponseMessage rm;
rm.SetID(id);
MessagePart result;
rm.SetResult(result);
- GetEndpointManager()->SendUnicastMessage(m_CheckerEndpoint, nrea.Sender, rm);
+ GetEndpointManager()->SendUnicastMessage(m_CheckerEndpoint, sender, rm);
}
}
-void CheckerComponent::ClearServicesRequestHandler(const NewRequestEventArgs& nrea)
+void CheckerComponent::ClearServicesRequestHandler(const Endpoint::Ptr& sender, const RequestMessage& request)
{
Application::Log(LogInformation, "checker", "Clearing service delegations.");
m_Services = ServiceQueue();
string id;
- if (nrea.Request.GetID(&id)) {
+ if (request.GetID(&id)) {
ResponseMessage rm;
rm.SetID(id);
MessagePart result;
rm.SetResult(result);
- GetEndpointManager()->SendUnicastMessage(m_CheckerEndpoint, nrea.Sender, rm);
+ GetEndpointManager()->SendUnicastMessage(m_CheckerEndpoint, sender, rm);
}
}
diff --git a/components/checker/checkercomponent.h b/components/checker/checkercomponent.h
index 7dca5ccce..080a50eb8 100644
--- a/components/checker/checkercomponent.h
+++ b/components/checker/checkercomponent.h
@@ -54,9 +54,9 @@ private:
void CheckTimerHandler(void);
- void AssignServiceRequestHandler(const NewRequestEventArgs& nrea);
- void RevokeServiceRequestHandler(const NewRequestEventArgs& nrea);
- void ClearServicesRequestHandler(const NewRequestEventArgs& nrea);
+ void AssignServiceRequestHandler(const Endpoint::Ptr& sender, const RequestMessage& request);
+ void RevokeServiceRequestHandler(const Endpoint::Ptr& sender, const RequestMessage& request);
+ void ClearServicesRequestHandler(const Endpoint::Ptr& sender, const RequestMessage& request);
};
}
diff --git a/components/configrpc/configrpccomponent.cpp b/components/configrpc/configrpccomponent.cpp
index 38ae78d31..a3ba0e0e3 100644
--- a/components/configrpc/configrpccomponent.cpp
+++ b/components/configrpc/configrpccomponent.cpp
@@ -35,23 +35,23 @@ void ConfigRpcComponent::Start(void)
long configSource;
if (GetConfig()->GetProperty("configSource", &configSource) && configSource != 0) {
m_ConfigRpcEndpoint->RegisterTopicHandler("config::FetchObjects",
- boost::bind(&ConfigRpcComponent::FetchObjectsHandler, this, _1));
+ boost::bind(&ConfigRpcComponent::FetchObjectsHandler, this, _2));
- ConfigObject::GetAllObjects()->OnObjectAdded.connect(boost::bind(&ConfigRpcComponent::LocalObjectCommittedHandler, this, _1));
- ConfigObject::GetAllObjects()->OnObjectCommitted.connect(boost::bind(&ConfigRpcComponent::LocalObjectCommittedHandler, this, _1));
- ConfigObject::GetAllObjects()->OnObjectRemoved.connect(boost::bind(&ConfigRpcComponent::LocalObjectRemovedHandler, this, _1));
+ ConfigObject::GetAllObjects()->OnObjectAdded.connect(boost::bind(&ConfigRpcComponent::LocalObjectCommittedHandler, this, _2));
+ ConfigObject::GetAllObjects()->OnObjectCommitted.connect(boost::bind(&ConfigRpcComponent::LocalObjectCommittedHandler, this, _2));
+ ConfigObject::GetAllObjects()->OnObjectRemoved.connect(boost::bind(&ConfigRpcComponent::LocalObjectRemovedHandler, this, _2));
m_ConfigRpcEndpoint->RegisterPublication("config::ObjectCommitted");
m_ConfigRpcEndpoint->RegisterPublication("config::ObjectRemoved");
}
- endpointManager->OnNewEndpoint.connect(boost::bind(&ConfigRpcComponent::NewEndpointHandler, this, _1));
+ endpointManager->OnNewEndpoint.connect(boost::bind(&ConfigRpcComponent::NewEndpointHandler, this, _2));
m_ConfigRpcEndpoint->RegisterPublication("config::FetchObjects");
m_ConfigRpcEndpoint->RegisterTopicHandler("config::ObjectCommitted",
- boost::bind(&ConfigRpcComponent::RemoteObjectCommittedHandler, this, _1));
+ boost::bind(&ConfigRpcComponent::RemoteObjectCommittedHandler, this, _3));
m_ConfigRpcEndpoint->RegisterTopicHandler("config::ObjectRemoved",
- boost::bind(&ConfigRpcComponent::RemoteObjectRemovedHandler, this, _1));
+ boost::bind(&ConfigRpcComponent::RemoteObjectRemovedHandler, this, _3));
endpointManager->RegisterEndpoint(m_ConfigRpcEndpoint);
}
@@ -64,17 +64,17 @@ void ConfigRpcComponent::Stop(void)
mgr->UnregisterEndpoint(m_ConfigRpcEndpoint);
}
-void ConfigRpcComponent::NewEndpointHandler(const NewEndpointEventArgs& ea)
+void ConfigRpcComponent::NewEndpointHandler(const Endpoint::Ptr& endpoint)
{
- ea.Endpoint->OnSessionEstablished.connect(boost::bind(&ConfigRpcComponent::SessionEstablishedHandler, this, _1));
+ endpoint->OnSessionEstablished.connect(boost::bind(&ConfigRpcComponent::SessionEstablishedHandler, this, _1));
}
-void ConfigRpcComponent::SessionEstablishedHandler(const EventArgs& ea)
+void ConfigRpcComponent::SessionEstablishedHandler(const Object::Ptr& source)
{
RequestMessage request;
request.SetMethod("config::FetchObjects");
- Endpoint::Ptr endpoint = static_pointer_cast(ea.Source);
+ Endpoint::Ptr endpoint = static_pointer_cast(source);
GetEndpointManager()->SendUnicastMessage(m_ConfigRpcEndpoint, endpoint, request);
}
@@ -100,9 +100,8 @@ bool ConfigRpcComponent::ShouldReplicateObject(const ConfigObject::Ptr& object)
return (!object->IsLocal());
}
-void ConfigRpcComponent::FetchObjectsHandler(const NewRequestEventArgs& ea)
+void ConfigRpcComponent::FetchObjectsHandler(const Endpoint::Ptr& sender)
{
- Endpoint::Ptr client = ea.Sender;
ConfigObject::Set::Ptr allObjects = ConfigObject::GetAllObjects();
for (ConfigObject::Set::Iterator ci = allObjects->Begin(); ci != allObjects->End(); ci++) {
@@ -113,14 +112,12 @@ void ConfigRpcComponent::FetchObjectsHandler(const NewRequestEventArgs& ea)
RequestMessage request = MakeObjectMessage(object, "config::ObjectCreated", true);
- GetEndpointManager()->SendUnicastMessage(m_ConfigRpcEndpoint, client, request);
+ GetEndpointManager()->SendUnicastMessage(m_ConfigRpcEndpoint, sender, request);
}
}
-void ConfigRpcComponent::LocalObjectCommittedHandler(const ObjectSetEventArgs& ea)
+void ConfigRpcComponent::LocalObjectCommittedHandler(const ConfigObject::Ptr& object)
{
- ConfigObject::Ptr object = ea.Target;
-
if (!ShouldReplicateObject(object))
return;
@@ -128,10 +125,8 @@ void ConfigRpcComponent::LocalObjectCommittedHandler(const ObjectSetEventArgs& ea)
+void ConfigRpcComponent::LocalObjectRemovedHandler(const ConfigObject::Ptr& object)
{
- ConfigObject::Ptr object = ea.Target;
-
if (!ShouldReplicateObject(object))
return;
@@ -139,12 +134,10 @@ void ConfigRpcComponent::LocalObjectRemovedHandler(const ObjectSetEventArgsCommit();
}
-void ConfigRpcComponent::RemoteObjectRemovedHandler(const NewRequestEventArgs& ea)
+void ConfigRpcComponent::RemoteObjectRemovedHandler(const RequestMessage& request)
{
- RequestMessage message = ea.Request;
-
MessagePart params;
- if (!message.GetParams(¶ms))
+ if (!request.GetParams(¶ms))
return;
string name;
diff --git a/components/configrpc/configrpccomponent.h b/components/configrpc/configrpccomponent.h
index 35d9fd875..696f6e01c 100644
--- a/components/configrpc/configrpccomponent.h
+++ b/components/configrpc/configrpccomponent.h
@@ -36,15 +36,15 @@ public:
private:
VirtualEndpoint::Ptr m_ConfigRpcEndpoint;
- void NewEndpointHandler(const NewEndpointEventArgs& ea);
- void SessionEstablishedHandler(const EventArgs& ea);
+ void NewEndpointHandler(const Endpoint::Ptr& endpoint);
+ void SessionEstablishedHandler(const Object::Ptr& source);
- void LocalObjectCommittedHandler(const ObjectSetEventArgs& ea);
- void LocalObjectRemovedHandler(const ObjectSetEventArgs& ea);
+ void LocalObjectCommittedHandler(const ConfigObject::Ptr& object);
+ void LocalObjectRemovedHandler(const ConfigObject::Ptr& object);
- void FetchObjectsHandler(const NewRequestEventArgs& ea);
- void RemoteObjectCommittedHandler(const NewRequestEventArgs& ea);
- void RemoteObjectRemovedHandler(const NewRequestEventArgs& ea);
+ void FetchObjectsHandler(const Endpoint::Ptr& sender);
+ void RemoteObjectCommittedHandler(const RequestMessage& request);
+ void RemoteObjectRemovedHandler(const RequestMessage& request);
static RequestMessage MakeObjectMessage(const ConfigObject::Ptr& object,
string method, bool includeProperties);
diff --git a/components/delegation/delegation.vcxproj.filters b/components/delegation/delegation.vcxproj.filters
new file mode 100644
index 000000000..3988c4ec0
--- /dev/null
+++ b/components/delegation/delegation.vcxproj.filters
@@ -0,0 +1,26 @@
+
+
+
+
+ {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
+ cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
+
+
+ {93995380-89BD-4b04-88EB-625FBE52EBFB}
+ h;hpp;hxx;hm;inl;inc;xsd
+
+
+
+
+ Quelldateien
+
+
+
+
+ Headerdateien
+
+
+ Headerdateien
+
+
+
\ No newline at end of file
diff --git a/components/delegation/delegationcomponent.cpp b/components/delegation/delegationcomponent.cpp
index 91cf71156..0a27018c3 100644
--- a/components/delegation/delegationcomponent.cpp
+++ b/components/delegation/delegationcomponent.cpp
@@ -29,9 +29,9 @@ string DelegationComponent::GetName(void) const
void DelegationComponent::Start(void)
{
m_AllServices = boost::make_shared(ConfigObject::GetAllObjects(), ConfigObject::MakeTypePredicate("service"));
- m_AllServices->OnObjectAdded.connect(boost::bind(&DelegationComponent::NewServiceHandler, this, _1));
- m_AllServices->OnObjectCommitted.connect(boost::bind(&DelegationComponent::NewServiceHandler, this, _1));
- m_AllServices->OnObjectRemoved.connect(boost::bind(&DelegationComponent::RemovedServiceHandler, this, _1));
+ m_AllServices->OnObjectAdded.connect(boost::bind(&DelegationComponent::NewServiceHandler, this, _2));
+ m_AllServices->OnObjectCommitted.connect(boost::bind(&DelegationComponent::NewServiceHandler, this, _2));
+ m_AllServices->OnObjectRemoved.connect(boost::bind(&DelegationComponent::RemovedServiceHandler, this, _2));
m_AllServices->Start();
m_DelegationTimer = boost::make_shared();
@@ -53,14 +53,14 @@ void DelegationComponent::Stop(void)
mgr->UnregisterEndpoint(m_DelegationEndpoint);
}
-void DelegationComponent::NewServiceHandler(const ObjectSetEventArgs& ea)
+void DelegationComponent::NewServiceHandler(const ConfigObject::Ptr& object)
{
- AssignService(ea.Target);
+ AssignService(object);
}
-void DelegationComponent::RemovedServiceHandler(const ObjectSetEventArgs& ea)
+void DelegationComponent::RemovedServiceHandler(const ConfigObject::Ptr& object)
{
- RevokeService(ea.Target);
+ RevokeService(object);
}
void DelegationComponent::AssignService(const ConfigObject::Ptr& service)
@@ -75,15 +75,15 @@ void DelegationComponent::AssignService(const ConfigObject::Ptr& service)
Application::Log(LogInformation, "delegation", "Trying to delegate service '" + service->GetName() + "'");
GetEndpointManager()->SendAPIMessage(m_DelegationEndpoint, request,
- boost::bind(&DelegationComponent::AssignServiceResponseHandler, this, service, _1));
+ boost::bind(&DelegationComponent::AssignServiceResponseHandler, this, service, _2, _5));
}
-void DelegationComponent::AssignServiceResponseHandler(const ConfigObject::Ptr& service, const NewResponseEventArgs& nrea)
+void DelegationComponent::AssignServiceResponseHandler(const ConfigObject::Ptr& service, const Endpoint::Ptr& sender, bool timedOut)
{
- if (nrea.TimedOut) {
+ if (timedOut) {
Application::Log(LogInformation, "delegation", "Service delegation for service '" + service->GetName() + "' timed out.");
} else {
- service->SetTag("checker", nrea.Sender->GetIdentity());
+ service->SetTag("checker", sender->GetIdentity());
Application::Log(LogInformation, "delegation", "Service delegation for service '" + service->GetName() + "' was successful.");
}
}
@@ -93,7 +93,7 @@ void DelegationComponent::RevokeService(const ConfigObject::Ptr& service)
}
-void DelegationComponent::RevokeServiceResponseHandler(const NewResponseEventArgs& nrea)
+void DelegationComponent::RevokeServiceResponseHandler(const ConfigObject::Ptr& service, const Endpoint::Ptr& sender, bool timedOut)
{
}
diff --git a/components/delegation/delegationcomponent.h b/components/delegation/delegationcomponent.h
index db8070701..d665fac73 100644
--- a/components/delegation/delegationcomponent.h
+++ b/components/delegation/delegationcomponent.h
@@ -38,11 +38,11 @@ private:
ConfigObject::Set::Ptr m_AllServices;
Timer::Ptr m_DelegationTimer;
- void NewServiceHandler(const ObjectSetEventArgs& ea);
- void RemovedServiceHandler(const ObjectSetEventArgs& ea);
+ void NewServiceHandler(const ConfigObject::Ptr& object);
+ void RemovedServiceHandler(const ConfigObject::Ptr& object);
- void AssignServiceResponseHandler(const ConfigObject::Ptr& service, const NewResponseEventArgs& nrea);
- void RevokeServiceResponseHandler(const NewResponseEventArgs& nrea);
+ void AssignServiceResponseHandler(const ConfigObject::Ptr& service, const Endpoint::Ptr& sender, bool timedOut);
+ void RevokeServiceResponseHandler(const ConfigObject::Ptr& service, const Endpoint::Ptr& sender, bool timedOut);
void DelegationTimerHandler(void);
diff --git a/components/demo/democomponent.cpp b/components/demo/democomponent.cpp
index f08272ec2..0fc006692 100644
--- a/components/demo/democomponent.cpp
+++ b/components/demo/democomponent.cpp
@@ -38,7 +38,7 @@ void DemoComponent::Start(void)
{
m_DemoEndpoint = boost::make_shared();
m_DemoEndpoint->RegisterTopicHandler("demo::HelloWorld",
- boost::bind(&DemoComponent::HelloWorldRequestHandler, this, _1));
+ boost::bind(&DemoComponent::HelloWorldRequestHandler, this, _2, _3));
m_DemoEndpoint->RegisterPublication("demo::HelloWorld");
GetEndpointManager()->RegisterEndpoint(m_DemoEndpoint);
@@ -80,9 +80,9 @@ void DemoComponent::DemoTimerHandler(void)
/**
* Processes demo::HelloWorld messages.
*/
-void DemoComponent::HelloWorldRequestHandler(const NewRequestEventArgs& nrea)
+void DemoComponent::HelloWorldRequestHandler(const Endpoint::Ptr& sender, const RequestMessage& request)
{
- Application::Log(LogInformation, "demo", "Got 'hello world' from address=" + nrea.Sender->GetAddress() + ", identity=" + nrea.Sender->GetIdentity());
+ Application::Log(LogInformation, "demo", "Got 'hello world' from address=" + sender->GetAddress() + ", identity=" + sender->GetIdentity());
}
EXPORT_COMPONENT(demo, DemoComponent);
diff --git a/components/demo/democomponent.h b/components/demo/democomponent.h
index e6341558f..92176fdc9 100644
--- a/components/demo/democomponent.h
+++ b/components/demo/democomponent.h
@@ -38,7 +38,7 @@ private:
VirtualEndpoint::Ptr m_DemoEndpoint;
void DemoTimerHandler(void);
- void HelloWorldRequestHandler(const NewRequestEventArgs& nrea);
+ void HelloWorldRequestHandler(const Endpoint::Ptr& sender, const RequestMessage& request);
};
}
diff --git a/components/discovery/discoverycomponent.cpp b/components/discovery/discoverycomponent.cpp
index 1bf293c6b..78df88da7 100644
--- a/components/discovery/discoverycomponent.cpp
+++ b/components/discovery/discoverycomponent.cpp
@@ -40,17 +40,17 @@ void DiscoveryComponent::Start(void)
m_DiscoveryEndpoint->RegisterPublication("discovery::RegisterComponent");
m_DiscoveryEndpoint->RegisterTopicHandler("discovery::RegisterComponent",
- boost::bind(&DiscoveryComponent::RegisterComponentMessageHandler, this, _1));
+ boost::bind(&DiscoveryComponent::RegisterComponentMessageHandler, this, _2, _3));
m_DiscoveryEndpoint->RegisterPublication("discovery::NewComponent");
m_DiscoveryEndpoint->RegisterTopicHandler("discovery::NewComponent",
- boost::bind(&DiscoveryComponent::NewComponentMessageHandler, this, _1));
+ boost::bind(&DiscoveryComponent::NewComponentMessageHandler, this, _3));
m_DiscoveryEndpoint->RegisterTopicHandler("discovery::Welcome",
- boost::bind(&DiscoveryComponent::WelcomeMessageHandler, this, _1));
+ boost::bind(&DiscoveryComponent::WelcomeMessageHandler, this, _2, _3));
- GetEndpointManager()->ForEachEndpoint(boost::bind(&DiscoveryComponent::NewEndpointHandler, this, _1));
- GetEndpointManager()->OnNewEndpoint.connect(boost::bind(&DiscoveryComponent::NewEndpointHandler, this, _1));
+ GetEndpointManager()->ForEachEndpoint(boost::bind(&DiscoveryComponent::NewEndpointHandler, this, _2));
+ GetEndpointManager()->OnNewEndpoint.connect(boost::bind(&DiscoveryComponent::NewEndpointHandler, this, _2));
GetEndpointManager()->RegisterEndpoint(m_DiscoveryEndpoint);
@@ -79,40 +79,39 @@ void DiscoveryComponent::Stop(void)
* Checks whether the specified endpoint is already connected
* and disconnects older endpoints.
*
- * @param endpoint The endpoint that is to be checked.
- * @param neea Event arguments for another endpoint.
+ * @param self The endpoint that is to be checked.
+ * @param other The other endpoint.
*/
-void DiscoveryComponent::CheckExistingEndpoint(Endpoint::Ptr endpoint, const NewEndpointEventArgs& neea)
+void DiscoveryComponent::CheckExistingEndpoint(const Endpoint::Ptr& self, const Endpoint::Ptr& other)
{
- if (endpoint == neea.Endpoint)
+ if (self == other)
return;
- if (!neea.Endpoint->IsConnected())
+ if (!other->IsConnected())
return;
- if (endpoint->GetIdentity() == neea.Endpoint->GetIdentity()) {
- Application::Log(LogWarning, "discovery", "Detected duplicate identity:" + endpoint->GetIdentity() + " - Disconnecting old endpoint.");
+ if (self->GetIdentity() == other->GetIdentity()) {
+ Application::Log(LogWarning, "discovery", "Detected duplicate identity:" + other->GetIdentity() + " - Disconnecting old endpoint.");
- neea.Endpoint->Stop();
- GetEndpointManager()->UnregisterEndpoint(neea.Endpoint);
+ other->Stop();
+ GetEndpointManager()->UnregisterEndpoint(other);
}
}
/**
* Registers handlers for new endpoints.
*
- * @param neea Event arguments for the new endpoint.
- * @returns 0
+ * @param endpoint The endpoint.
*/
-void DiscoveryComponent::NewEndpointHandler(const NewEndpointEventArgs& neea)
+void DiscoveryComponent::NewEndpointHandler(const Endpoint::Ptr& endpoint)
{
- neea.Endpoint->OnIdentityChanged.connect(boost::bind(&DiscoveryComponent::NewIdentityHandler, this, _1));
+ endpoint->OnIdentityChanged.connect(boost::bind(&DiscoveryComponent::NewIdentityHandler, this, _1));
/* accept discovery::RegisterComponent messages from any endpoint */
- neea.Endpoint->RegisterPublication("discovery::RegisterComponent");
+ endpoint->RegisterPublication("discovery::RegisterComponent");
/* accept discovery::Welcome messages from any endpoint */
- neea.Endpoint->RegisterPublication("discovery::Welcome");
+ endpoint->RegisterPublication("discovery::Welcome");
}
/**
@@ -122,17 +121,15 @@ void DiscoveryComponent::NewEndpointHandler(const NewEndpointEventArgs& neea)
* @param info Component information object.
* @return 0
*/
-void DiscoveryComponent::DiscoveryEndpointHandler(const NewEndpointEventArgs& neea, ComponentDiscoveryInfo::Ptr info) const
+void DiscoveryComponent::DiscoveryEndpointHandler(const Endpoint::Ptr& endpoint, const ComponentDiscoveryInfo::Ptr& info) const
{
Endpoint::ConstTopicIterator i;
- for (i = neea.Endpoint->BeginSubscriptions(); i != neea.Endpoint->EndSubscriptions(); i++) {
+ for (i = endpoint->BeginSubscriptions(); i != endpoint->EndSubscriptions(); i++)
info->Subscriptions.insert(*i);
- }
- for (i = neea.Endpoint->BeginPublications(); i != neea.Endpoint->EndPublications(); i++) {
+ for (i = endpoint->BeginPublications(); i != endpoint->EndPublications(); i++)
info->Publications.insert(*i);
- }
}
/**
@@ -147,7 +144,7 @@ bool DiscoveryComponent::GetComponentDiscoveryInfo(string component, ComponentDi
if (component == GetEndpointManager()->GetIdentity()) {
/* Build fake discovery info for ourselves */
*info = boost::make_shared();
- GetEndpointManager()->ForEachEndpoint(boost::bind(&DiscoveryComponent::DiscoveryEndpointHandler, this, _1, *info));
+ GetEndpointManager()->ForEachEndpoint(boost::bind(&DiscoveryComponent::DiscoveryEndpointHandler, this, _2, *info));
(*info)->LastSeen = 0;
(*info)->Node = GetIcingaApplication()->GetNode();
@@ -173,9 +170,9 @@ bool DiscoveryComponent::GetComponentDiscoveryInfo(string component, ComponentDi
* @param ea Event arguments for the component.
* @returns 0
*/
-void DiscoveryComponent::NewIdentityHandler(const EventArgs& ea)
+void DiscoveryComponent::NewIdentityHandler(const Object::Ptr& source)
{
- Endpoint::Ptr endpoint = static_pointer_cast(ea.Source);
+ Endpoint::Ptr endpoint = static_pointer_cast(source);
string identity = endpoint->GetIdentity();
if (identity == GetEndpointManager()->GetIdentity()) {
@@ -187,7 +184,7 @@ void DiscoveryComponent::NewIdentityHandler(const EventArgs& ea)
return;
}
- GetEndpointManager()->ForEachEndpoint(boost::bind(&DiscoveryComponent::CheckExistingEndpoint, this, endpoint, _1));
+ GetEndpointManager()->ForEachEndpoint(boost::bind(&DiscoveryComponent::CheckExistingEndpoint, this, endpoint, _2));
// we assume the other component _always_ wants
// discovery::RegisterComponent messages from us
@@ -241,20 +238,15 @@ void DiscoveryComponent::NewIdentityHandler(const EventArgs& ea)
* @param nrea Event arguments for the request.
* @returns 0
*/
-void DiscoveryComponent::WelcomeMessageHandler(const NewRequestEventArgs& nrea)
+void DiscoveryComponent::WelcomeMessageHandler(const Endpoint::Ptr& sender, const RequestMessage& request)
{
- Endpoint::Ptr endpoint = nrea.Sender;
-
- if (endpoint->HasReceivedWelcome())
+ if (sender->HasReceivedWelcome())
return;
- endpoint->SetReceivedWelcome(true);
+ sender->SetReceivedWelcome(true);
- if (endpoint->HasSentWelcome()) {
- EventArgs ea;
- ea.Source = endpoint;
- endpoint->OnSessionEstablished(ea);
- }
+ if (sender->HasSentWelcome())
+ sender->OnSessionEstablished(sender);
}
/**
@@ -264,7 +256,7 @@ void DiscoveryComponent::WelcomeMessageHandler(const NewRequestEventArgs& nrea)
*
* @param endpoint The endpoint to set up.
*/
-void DiscoveryComponent::FinishDiscoverySetup(Endpoint::Ptr endpoint)
+void DiscoveryComponent::FinishDiscoverySetup(const Endpoint::Ptr& endpoint)
{
if (endpoint->HasSentWelcome())
return;
@@ -278,11 +270,8 @@ void DiscoveryComponent::FinishDiscoverySetup(Endpoint::Ptr endpoint)
endpoint->SetSentWelcome(true);
- if (endpoint->HasReceivedWelcome()) {
- EventArgs ea;
- ea.Source = endpoint;
- endpoint->OnSessionEstablished(ea);
- }
+ if (endpoint->HasReceivedWelcome())
+ endpoint->OnSessionEstablished(endpoint);
}
/**
@@ -293,7 +282,7 @@ void DiscoveryComponent::FinishDiscoverySetup(Endpoint::Ptr endpoint)
* @param identity The identity of the component for which a message should be sent.
* @param recipient The recipient of the message. A multicast message is sent if this parameter is empty.
*/
-void DiscoveryComponent::SendDiscoveryMessage(string method, string identity, Endpoint::Ptr recipient)
+void DiscoveryComponent::SendDiscoveryMessage(const string& method, const string& identity, const Endpoint::Ptr& recipient)
{
RequestMessage request;
request.SetMethod(method);
@@ -332,7 +321,7 @@ void DiscoveryComponent::SendDiscoveryMessage(string method, string identity, En
GetEndpointManager()->SendMulticastMessage(m_DiscoveryEndpoint, request);
}
-bool DiscoveryComponent::HasMessagePermission(Dictionary::Ptr roles, string messageType, string message)
+bool DiscoveryComponent::HasMessagePermission(const Dictionary::Ptr& roles, const string& messageType, const string& message)
{
if (!roles)
return false;
@@ -367,7 +356,7 @@ bool DiscoveryComponent::HasMessagePermission(Dictionary::Ptr roles, string mess
* @param message The discovery message.
* @param trusted Whether the message comes from a trusted source (i.e. a broker).
*/
-void DiscoveryComponent::ProcessDiscoveryMessage(string identity, DiscoveryMessage message, bool trusted)
+void DiscoveryComponent::ProcessDiscoveryMessage(const string& identity, const DiscoveryMessage& message, bool trusted)
{
/* ignore discovery messages that are about ourselves */
if (identity == GetEndpointManager()->GetIdentity())
@@ -438,10 +427,10 @@ void DiscoveryComponent::ProcessDiscoveryMessage(string identity, DiscoveryMessa
*
* @param nrea Event arguments for the request.
*/
-void DiscoveryComponent::NewComponentMessageHandler(const NewRequestEventArgs& nrea)
+void DiscoveryComponent::NewComponentMessageHandler(const RequestMessage& request)
{
DiscoveryMessage message;
- nrea.Request.GetParams(&message);
+ request.GetParams(&message);
string identity;
if (!message.GetIdentity(&identity))
@@ -455,11 +444,11 @@ void DiscoveryComponent::NewComponentMessageHandler(const NewRequestEventArgs& n
*
* @param nrea Event arguments for the request.
*/
-void DiscoveryComponent::RegisterComponentMessageHandler(const NewRequestEventArgs& nrea)
+void DiscoveryComponent::RegisterComponentMessageHandler(const Endpoint::Ptr& sender, const RequestMessage& request)
{
DiscoveryMessage message;
- nrea.Request.GetParams(&message);
- ProcessDiscoveryMessage(nrea.Sender->GetIdentity(), message, false);
+ request.GetParams(&message);
+ ProcessDiscoveryMessage(sender->GetIdentity(), message, false);
}
/**
diff --git a/components/discovery/discoverycomponent.h b/components/discovery/discoverycomponent.h
index 3e3ec83a9..39172f96f 100644
--- a/components/discovery/discoverycomponent.h
+++ b/components/discovery/discoverycomponent.h
@@ -56,27 +56,27 @@ private:
map m_Components;
Timer::Ptr m_DiscoveryTimer;
- void NewEndpointHandler(const NewEndpointEventArgs& neea);
- void NewIdentityHandler(const EventArgs& ea);
+ void NewEndpointHandler(const Endpoint::Ptr& endpoint);
+ void NewIdentityHandler(const Object::Ptr& source);
- void NewComponentMessageHandler(const NewRequestEventArgs& nrea);
- void RegisterComponentMessageHandler(const NewRequestEventArgs& nrea);
+ void NewComponentMessageHandler(const RequestMessage& request);
+ void RegisterComponentMessageHandler(const Endpoint::Ptr& sender, const RequestMessage& request);
- void WelcomeMessageHandler(const NewRequestEventArgs& nrea);
+ void WelcomeMessageHandler(const Endpoint::Ptr& sender, const RequestMessage& request);
- void SendDiscoveryMessage(string method, string identity, Endpoint::Ptr recipient);
- void ProcessDiscoveryMessage(string identity, DiscoveryMessage message, bool trusted);
+ void SendDiscoveryMessage(const string& method, const string& identity, const Endpoint::Ptr& recipient);
+ void ProcessDiscoveryMessage(const string& identity, const DiscoveryMessage& message, bool trusted);
bool GetComponentDiscoveryInfo(string component, ComponentDiscoveryInfo::Ptr *info) const;
- void CheckExistingEndpoint(Endpoint::Ptr endpoint, const NewEndpointEventArgs& neea);
- void DiscoveryEndpointHandler(const NewEndpointEventArgs& neea, ComponentDiscoveryInfo::Ptr info) const;
+ void CheckExistingEndpoint(const Endpoint::Ptr& self, const Endpoint::Ptr& other);
+ void DiscoveryEndpointHandler(const Endpoint::Ptr& endpoint, const ComponentDiscoveryInfo::Ptr& info) const;
void DiscoveryTimerHandler(void);
- void FinishDiscoverySetup(Endpoint::Ptr endpoint);
+ void FinishDiscoverySetup(const Endpoint::Ptr& endpoint);
- bool HasMessagePermission(Dictionary::Ptr roles, string messageType, string message);
+ bool HasMessagePermission(const Dictionary::Ptr& roles, const string& messageType, const string& message);
static const int RegistrationTTL = 300;
};
diff --git a/dyntest/dyntest.vcxproj.filters b/dyntest/dyntest.vcxproj.filters
new file mode 100644
index 000000000..5fa60e082
--- /dev/null
+++ b/dyntest/dyntest.vcxproj.filters
@@ -0,0 +1,22 @@
+
+
+
+
+ {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
+ cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
+
+
+ {93995380-89BD-4b04-88EB-625FBE52EBFB}
+ h;hpp;hxx;hm;inl;inc;xsd
+
+
+ {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
+ rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
+
+
+
+
+ Quelldateien
+
+
+
\ No newline at end of file
diff --git a/icinga/endpoint.cpp b/icinga/endpoint.cpp
index 94c015e7a..980693137 100644
--- a/icinga/endpoint.cpp
+++ b/icinga/endpoint.cpp
@@ -48,10 +48,7 @@ string Endpoint::GetIdentity(void) const
void Endpoint::SetIdentity(string identity)
{
m_Identity = identity;
-
- EventArgs ea;
- ea.Source = shared_from_this();
- OnIdentityChanged(ea);
+ OnIdentityChanged(shared_from_this());
}
/**
diff --git a/icinga/endpoint.h b/icinga/endpoint.h
index a9bb89168..46848cd28 100644
--- a/icinga/endpoint.h
+++ b/icinga/endpoint.h
@@ -79,8 +79,8 @@ public:
ConstTopicIterator BeginPublications(void) const;
ConstTopicIterator EndPublications(void) const;
- boost::signal OnIdentityChanged;
- boost::signal OnSessionEstablished;
+ boost::signal OnIdentityChanged;
+ boost::signal OnSessionEstablished;
private:
string m_Identity; /**< The identity of this endpoint. */
diff --git a/icinga/endpointmanager.cpp b/icinga/endpointmanager.cpp
index fa310c542..c3b11d59a 100644
--- a/icinga/endpointmanager.cpp
+++ b/icinga/endpointmanager.cpp
@@ -110,7 +110,7 @@ void EndpointManager::RegisterServer(JsonRpcServer::Ptr server)
{
m_Servers.push_back(server);
server->OnNewClient.connect(boost::bind(&EndpointManager::NewClientHandler,
- this, _1));
+ this, _2));
}
/**
@@ -118,13 +118,12 @@ void EndpointManager::RegisterServer(JsonRpcServer::Ptr server)
*
* @param ncea Event arguments.
*/
-void EndpointManager::NewClientHandler(const NewClientEventArgs& ncea)
+void EndpointManager::NewClientHandler(const TcpClient::Ptr& client)
{
- string address = ncea.Client->GetPeerAddress();
- Application::Log(LogInformation, "icinga", "Accepted new client from " + address);
+ Application::Log(LogInformation, "icinga", "Accepted new client from " + client->GetPeerAddress());
JsonRpcEndpoint::Ptr endpoint = boost::make_shared();
- endpoint->SetClient(static_pointer_cast(ncea.Client));
+ endpoint->SetClient(static_pointer_cast(client));
RegisterEndpoint(endpoint);
}
@@ -154,10 +153,7 @@ void EndpointManager::RegisterEndpoint(Endpoint::Ptr endpoint)
endpoint->SetEndpointManager(static_pointer_cast(shared_from_this()));
m_Endpoints.push_back(endpoint);
- NewEndpointEventArgs neea;
- neea.Source = shared_from_this();
- neea.Endpoint = endpoint;
- OnNewEndpoint(neea);
+ OnNewEndpoint(shared_from_this(), endpoint);
}
/**
@@ -257,18 +253,14 @@ void EndpointManager::SendMulticastMessage(Endpoint::Ptr sender,
*
* @param callback The callback function.
*/
-void EndpointManager::ForEachEndpoint(function callback)
+void EndpointManager::ForEachEndpoint(function callback)
{
- NewEndpointEventArgs neea;
- neea.Source = shared_from_this();
-
vector::iterator prev, i;
for (i = m_Endpoints.begin(); i != m_Endpoints.end(); ) {
prev = i;
i++;
- neea.Endpoint = *prev;
- callback(neea);
+ callback(shared_from_this(), *prev);
}
}
@@ -290,7 +282,7 @@ Endpoint::Ptr EndpointManager::GetEndpointByIdentity(string identity) const
void EndpointManager::SendAPIMessage(Endpoint::Ptr sender,
RequestMessage& message,
- function callback, time_t timeout)
+ function callback, time_t timeout)
{
m_NextMessageID++;
@@ -345,12 +337,7 @@ void EndpointManager::RequestTimerHandler(void)
map::iterator it;
for (it = m_Requests.begin(); it != m_Requests.end(); it++) {
if (it->second.HasTimedOut()) {
- NewResponseEventArgs nrea;
- nrea.Request = it->second.Request;
- nrea.Source = shared_from_this();
- nrea.TimedOut = true;
-
- it->second.Callback(nrea);
+ it->second.Callback(shared_from_this(), Endpoint::Ptr(), it->second.Request, ResponseMessage(), true);
m_Requests.erase(it);
@@ -373,14 +360,7 @@ void EndpointManager::ProcessResponseMessage(const Endpoint::Ptr& sender, const
if (it == m_Requests.end())
return;
- NewResponseEventArgs nrea;
- nrea.Sender = sender;
- nrea.Request = it->second.Request;
- nrea.Response = message;
- nrea.Source = shared_from_this();
- nrea.TimedOut = false;
-
- it->second.Callback(nrea);
+ it->second.Callback(shared_from_this(), sender, it->second.Request, message, false);
m_Requests.erase(it);
RescheduleRequestTimer();
diff --git a/icinga/endpointmanager.h b/icinga/endpointmanager.h
index 8636f1e8b..7c31740b4 100644
--- a/icinga/endpointmanager.h
+++ b/icinga/endpointmanager.h
@@ -23,18 +23,6 @@
namespace icinga
{
-/**
- * Event arguments for the "new endpoint registered" event.
- *
- * @ingroup icinga
- */
-struct I2_ICINGA_API NewEndpointEventArgs : public EventArgs
-{
- icinga::Endpoint::Ptr Endpoint; /**< The new endpoint. */
-};
-
-struct NewResponseEventArgs;
-
/**
* Information about a pending API request.
*
@@ -44,7 +32,7 @@ struct I2_ICINGA_API PendingRequest
{
time_t Timeout;
RequestMessage Request;
- function Callback;
+ function Callback;
bool HasTimedOut(void) const
{
@@ -52,19 +40,6 @@ struct I2_ICINGA_API PendingRequest
}
};
-/**
- * Event arguments for the "new response" event.
- *
- * @ingroup icinga
- */
-struct I2_ICINGA_API NewResponseEventArgs : public EventArgs
-{
- Endpoint::Ptr Sender;
- RequestMessage Request;
- ResponseMessage Response;
- bool TimedOut;
-};
-
/**
* Forwards messages between endpoints.
*
@@ -97,15 +72,15 @@ public:
void SendMulticastMessage(Endpoint::Ptr sender, const RequestMessage& message);
void SendAPIMessage(Endpoint::Ptr sender, RequestMessage& message,
- function callback, time_t timeout = 10);
+ function callback, time_t timeout = 10);
void ProcessResponseMessage(const Endpoint::Ptr& sender, const ResponseMessage& message);
- void ForEachEndpoint(function callback);
+ void ForEachEndpoint(function callback);
Endpoint::Ptr GetEndpointByIdentity(string identity) const;
- boost::signal OnNewEndpoint;
+ boost::signal OnNewEndpoint;
private:
string m_Identity;
@@ -125,7 +100,7 @@ private:
void RescheduleRequestTimer(void);
void RequestTimerHandler(void);
- void NewClientHandler(const NewClientEventArgs& ncea);
+ void NewClientHandler(const TcpClient::Ptr& client);
};
}
diff --git a/icinga/icingaapplication.cpp b/icinga/icingaapplication.cpp
index 4780298e7..7955eb161 100644
--- a/icinga/icingaapplication.cpp
+++ b/icinga/icingaapplication.cpp
@@ -56,10 +56,9 @@ int IcingaApplication::Main(const vector& args)
/* register handler for 'component' config objects */
static ConfigObject::Set::Ptr componentObjects = boost::make_shared(ConfigObject::GetAllObjects(), ConfigObject::MakeTypePredicate("component"));
- function&)> NewComponentHandler = boost::bind(&IcingaApplication::NewComponentHandler, this, _1);
- componentObjects->OnObjectAdded.connect(NewComponentHandler);
- componentObjects->OnObjectCommitted.connect(NewComponentHandler);
- componentObjects->OnObjectRemoved.connect(boost::bind(&IcingaApplication::DeletedComponentHandler, this, _1));
+ componentObjects->OnObjectAdded.connect(boost::bind(&IcingaApplication::NewComponentHandler, this, _2));
+ componentObjects->OnObjectCommitted.connect(boost::bind(&IcingaApplication::NewComponentHandler, this, _2));
+ componentObjects->OnObjectRemoved.connect(boost::bind(&IcingaApplication::DeletedComponentHandler, this, _2));
componentObjects->Start();
/* load config file */
@@ -113,10 +112,8 @@ EndpointManager::Ptr IcingaApplication::GetEndpointManager(void)
return m_EndpointManager;
}
-void IcingaApplication::NewComponentHandler(const ObjectSetEventArgs& ea)
+void IcingaApplication::NewComponentHandler(const ConfigObject::Ptr& object)
{
- ConfigObject::Ptr object = ea.Target;
-
/* don't allow replicated config objects */
if (!object->IsLocal())
throw runtime_error("'component' objects must be 'local'");
@@ -133,10 +130,8 @@ void IcingaApplication::NewComponentHandler(const ObjectSetEventArgs& ea)
+void IcingaApplication::DeletedComponentHandler(const ConfigObject::Ptr& object)
{
- ConfigObject::Ptr object = ea.Target;
-
Component::Ptr component = GetComponent(object->GetName());
UnregisterComponent(component);
}
diff --git a/icinga/icingaapplication.h b/icinga/icingaapplication.h
index 6b928d129..4dbfb00d2 100644
--- a/icinga/icingaapplication.h
+++ b/icinga/icingaapplication.h
@@ -53,8 +53,8 @@ private:
string m_Node;
string m_Service;
- void NewComponentHandler(const ObjectSetEventArgs& ea);
- void DeletedComponentHandler(const ObjectSetEventArgs& ea);
+ void NewComponentHandler(const ConfigObject::Ptr& object);
+ void DeletedComponentHandler(const ConfigObject::Ptr& object);
};
}
diff --git a/icinga/jsonrpcendpoint.cpp b/icinga/jsonrpcendpoint.cpp
index 594141c6a..a9dfc1f73 100644
--- a/icinga/jsonrpcendpoint.cpp
+++ b/icinga/jsonrpcendpoint.cpp
@@ -45,10 +45,10 @@ void JsonRpcEndpoint::Connect(string node, string service, shared_ptr s
void JsonRpcEndpoint::SetClient(JsonRpcClient::Ptr client)
{
m_Client = client;
- client->OnNewMessage.connect(boost::bind(&JsonRpcEndpoint::NewMessageHandler, this, _1));
- client->OnClosed.connect(boost::bind(&JsonRpcEndpoint::ClientClosedHandler, this, _1));
- client->OnError.connect(boost::bind(&JsonRpcEndpoint::ClientErrorHandler, this, _1));
- client->OnVerifyCertificate.connect(boost::bind(&JsonRpcEndpoint::VerifyCertificateHandler, this, _1));
+ client->OnNewMessage.connect(boost::bind(&JsonRpcEndpoint::NewMessageHandler, this, _2));
+ client->OnClosed.connect(boost::bind(&JsonRpcEndpoint::ClientClosedHandler, this));
+ client->OnError.connect(boost::bind(&JsonRpcEndpoint::ClientErrorHandler, this, _2));
+ client->OnVerifyCertificate.connect(boost::bind(&JsonRpcEndpoint::VerifyCertificateHandler, this, _2, _4));
}
bool JsonRpcEndpoint::IsLocal(void) const
@@ -80,9 +80,8 @@ void JsonRpcEndpoint::ProcessResponse(Endpoint::Ptr sender, const ResponseMessag
m_Client->SendMessage(message);
}
-void JsonRpcEndpoint::NewMessageHandler(const NewMessageEventArgs& nmea)
+void JsonRpcEndpoint::NewMessageHandler(const MessagePart& message)
{
- const MessagePart& message = nmea.Message;
Endpoint::Ptr sender = static_pointer_cast(shared_from_this());
if (ResponseMessage::IsResponseMessage(message)) {
@@ -108,7 +107,7 @@ void JsonRpcEndpoint::NewMessageHandler(const NewMessageEventArgs& nmea)
GetEndpointManager()->SendMulticastMessage(sender, request);
}
-void JsonRpcEndpoint::ClientClosedHandler(const EventArgs&)
+void JsonRpcEndpoint::ClientClosedHandler(void)
{
Application::Log(LogWarning, "jsonrpc", "Lost connection to endpoint: identity=" + GetIdentity());
@@ -130,18 +129,18 @@ void JsonRpcEndpoint::ClientClosedHandler(const EventArgs&)
// TODO: persist events, etc., for now we just disable the endpoint
}
-void JsonRpcEndpoint::ClientErrorHandler(const SocketErrorEventArgs& ea)
+void JsonRpcEndpoint::ClientErrorHandler(const std::exception& ex)
{
stringstream message;
- message << "Error occured for JSON-RPC socket: Message=" << ea.Exception.what();
+ message << "Error occured for JSON-RPC socket: Message=" << ex.what();
Application::Log(LogWarning, "jsonrpc", message.str());
}
-void JsonRpcEndpoint::VerifyCertificateHandler(const VerifyCertificateEventArgs& ea)
+void JsonRpcEndpoint::VerifyCertificateHandler(bool& valid, const shared_ptr& certificate)
{
- if (ea.Certificate && ea.ValidCertificate) {
- string identity = Utility::GetCertificateCN(ea.Certificate);
+ if (certificate && valid) {
+ string identity = Utility::GetCertificateCN(certificate);
if (GetIdentity().empty() && !identity.empty())
SetIdentity(identity);
diff --git a/icinga/jsonrpcendpoint.h b/icinga/jsonrpcendpoint.h
index 2c07eb54e..d566b9f3f 100644
--- a/icinga/jsonrpcendpoint.h
+++ b/icinga/jsonrpcendpoint.h
@@ -58,10 +58,10 @@ private:
JsonRpcClient::Ptr m_Client;
map m_PendingCalls;
- void NewMessageHandler(const NewMessageEventArgs& nmea);
- void ClientClosedHandler(const EventArgs& ea);
- void ClientErrorHandler(const SocketErrorEventArgs& ea);
- void VerifyCertificateHandler(const VerifyCertificateEventArgs& ea);
+ void NewMessageHandler(const MessagePart& message);
+ void ClientClosedHandler(void);
+ void ClientErrorHandler(const std::exception& ex);
+ void VerifyCertificateHandler(bool& valid, const shared_ptr& certificate);
};
}
diff --git a/icinga/virtualendpoint.cpp b/icinga/virtualendpoint.cpp
index 8737d9ff3..02ff52efe 100644
--- a/icinga/virtualendpoint.cpp
+++ b/icinga/virtualendpoint.cpp
@@ -38,15 +38,15 @@ bool VirtualEndpoint::IsConnected(void) const
return true;
}
-void VirtualEndpoint::RegisterTopicHandler(string topic, function callback)
+void VirtualEndpoint::RegisterTopicHandler(string topic, function callback)
{
- map > >::iterator it;
+ map > >::iterator it;
it = m_TopicHandlers.find(topic);
- shared_ptr > sig;
+ shared_ptr > sig;
if (it == m_TopicHandlers.end()) {
- sig = boost::make_shared >();
+ sig = boost::make_shared >();
m_TopicHandlers.insert(make_pair(topic, sig));
} else {
sig = it->second;
@@ -57,7 +57,7 @@ void VirtualEndpoint::RegisterTopicHandler(string topic, function callback)
+void VirtualEndpoint::UnregisterTopicHandler(string topic, function callback)
{
// TODO: implement
//m_TopicHandlers[method] -= callback;
@@ -72,17 +72,13 @@ void VirtualEndpoint::ProcessRequest(Endpoint::Ptr sender, const RequestMessage&
if (!request.GetMethod(&method))
return;
- map > >::iterator it;
+ map > >::iterator it;
it = m_TopicHandlers.find(method);
if (it == m_TopicHandlers.end())
return;
- NewRequestEventArgs nrea;
- nrea.Source = shared_from_this();
- nrea.Sender = sender;
- nrea.Request = request;
- (*it->second)(nrea);
+ (*it->second)(shared_from_this(), sender, request);
}
void VirtualEndpoint::ProcessResponse(Endpoint::Ptr sender, const ResponseMessage& response)
diff --git a/icinga/virtualendpoint.h b/icinga/virtualendpoint.h
index 9e42f34a9..4da70c053 100644
--- a/icinga/virtualendpoint.h
+++ b/icinga/virtualendpoint.h
@@ -23,17 +23,6 @@
namespace icinga
{
-/**
- * Event arguments for the "new request" event.
- *
- * @ingroup icinga
- */
-struct I2_ICINGA_API NewRequestEventArgs : public EventArgs
-{
- Endpoint::Ptr Sender;
- RequestMessage Request;
-};
-
/**
* A local endpoint.
*
@@ -45,8 +34,8 @@ public:
typedef shared_ptr Ptr;
typedef weak_ptr WeakPtr;
- void RegisterTopicHandler(string topic, function callback);
- void UnregisterTopicHandler(string topic, function callback);
+ void RegisterTopicHandler(string topic, function callback);
+ void UnregisterTopicHandler(string topic, function callback);
virtual string GetAddress(void) const;
@@ -59,7 +48,7 @@ public:
virtual void Stop(void);
private:
- map< string, shared_ptr > > m_TopicHandlers;
+ map< string, shared_ptr > > m_TopicHandlers;
};
}
diff --git a/jsonrpc/jsonrpcclient.cpp b/jsonrpc/jsonrpcclient.cpp
index e7ce12ce2..e35e76f08 100644
--- a/jsonrpc/jsonrpcclient.cpp
+++ b/jsonrpc/jsonrpcclient.cpp
@@ -28,13 +28,9 @@ using namespace icinga;
* @param sslContext SSL context for the TLS connection.
*/
JsonRpcClient::JsonRpcClient(TcpClientRole role, shared_ptr sslContext)
- : TlsClient(role, sslContext) { }
-
-void JsonRpcClient::Start(void)
+ : TlsClient(role, sslContext)
{
- TlsClient::Start();
-
- OnDataAvailable.connect(boost::bind(&JsonRpcClient::DataAvailableHandler, this, _1));
+ OnDataAvailable.connect(boost::bind(&JsonRpcClient::DataAvailableHandler, this));
}
/**
@@ -49,11 +45,8 @@ void JsonRpcClient::SendMessage(const MessagePart& message)
/**
* Processes inbound data.
- *
- * @param - Event arguments for the event.
- * @returns 0
*/
-void JsonRpcClient::DataAvailableHandler(const EventArgs&)
+void JsonRpcClient::DataAvailableHandler(void)
{
for (;;) {
try {
@@ -64,11 +57,7 @@ void JsonRpcClient::DataAvailableHandler(const EventArgs&)
return;
message = MessagePart(jsonString);
-
- NewMessageEventArgs nea;
- nea.Source = shared_from_this();
- nea.Message = message;
- OnNewMessage(nea);
+ OnNewMessage(shared_from_this(), message);
} catch (const Exception& ex) {
Application::Log(LogCritical, "jsonrpc", "Exception while processing message from JSON-RPC client: " + string(ex.GetMessage()));
Close();
diff --git a/jsonrpc/jsonrpcclient.h b/jsonrpc/jsonrpcclient.h
index 384dff3c4..a8f962884 100644
--- a/jsonrpc/jsonrpcclient.h
+++ b/jsonrpc/jsonrpcclient.h
@@ -23,16 +23,6 @@
namespace icinga
{
-/**
- * Event arguments for the "new message" event.
- *
- * @ingroup jsonrpc
- */
-struct I2_JSONRPC_API NewMessageEventArgs : public EventArgs
-{
- icinga::MessagePart Message;
-};
-
/**
* A JSON-RPC client.
*
@@ -48,12 +38,10 @@ public:
void SendMessage(const MessagePart& message);
- virtual void Start(void);
-
- boost::signal OnNewMessage;
+ boost::signal OnNewMessage;
private:
- void DataAvailableHandler(const EventArgs&);
+ void DataAvailableHandler(void);
};
JsonRpcClient::Ptr JsonRpcClientFactory(TcpClientRole role, shared_ptr sslContext);
diff --git a/jsonrpc/netstring.cpp b/jsonrpc/netstring.cpp
index 57b705640..de1104544 100644
--- a/jsonrpc/netstring.cpp
+++ b/jsonrpc/netstring.cpp
@@ -82,12 +82,12 @@ bool Netstring::ReadStringFromFIFO(FIFO::Ptr fifo, string *str)
*/
void Netstring::WriteStringToFIFO(FIFO::Ptr fifo, const string& str)
{
- unsigned long len = str.size();
- char strLength[50];
- sprintf(strLength, "%lu:", (unsigned long)len);
+ stringstream prefixbuf;
+ prefixbuf << str.size() << ":";
- fifo->Write(strLength, strlen(strLength));
- fifo->Write(str.c_str(), len);
+ string prefix = prefixbuf.str();
+ fifo->Write(prefix.c_str(), prefix.size());
+ fifo->Write(str.c_str(), str.size());
fifo->Write(",", 1);
}