icinga2/icinga/virtualendpoint.cpp

49 lines
1.2 KiB
C++
Raw Normal View History

#include "i2-icinga.h"
using namespace icinga;
2012-04-18 15:22:25 +02:00
bool VirtualEndpoint::IsLocal(void) const
{
return true;
}
void VirtualEndpoint::RegisterMethodHandler(string method, function<int (const NewRequestEventArgs&)> callback)
{
m_MethodHandlers[method] += callback;
2012-04-16 16:27:41 +02:00
RegisterMethodSink(method);
}
2012-04-18 15:22:25 +02:00
void VirtualEndpoint::UnregisterMethodHandler(string method, function<int (const NewRequestEventArgs&)> callback)
{
// TODO: implement
2012-04-16 16:27:41 +02:00
//m_MethodHandlers[method] -= callback;
//UnregisterMethodSink(method);
2012-04-16 16:27:41 +02:00
throw NotImplementedException();
}
2012-04-18 15:22:25 +02:00
void VirtualEndpoint::ProcessRequest(Endpoint::Ptr sender, const JsonRpcRequest& request)
{
2012-04-16 16:27:41 +02:00
string method;
2012-04-18 15:22:25 +02:00
if (!request.GetMethod(&method))
2012-04-16 16:27:41 +02:00
return;
2012-04-18 15:22:25 +02:00
map<string, Event<NewRequestEventArgs> >::iterator i = m_MethodHandlers.find(method);
2012-04-16 16:27:41 +02:00
if (i == m_MethodHandlers.end())
throw InvalidArgumentException();
2012-04-18 15:22:25 +02:00
NewRequestEventArgs nrea;
nrea.Source = shared_from_this();
nrea.Sender = sender;
nrea.Request = request;
2012-04-16 16:27:41 +02:00
i->second(nrea);
}
2012-04-18 15:22:25 +02:00
void VirtualEndpoint::ProcessResponse(Endpoint::Ptr sender, const JsonRpcResponse& response)
{
2012-04-16 16:27:41 +02:00
// TODO: figure out which request this response belongs to and notify the caller
throw NotImplementedException();
}