icinga2/icinga/virtualendpoint.cpp

44 lines
1.1 KiB
C++
Raw Normal View History

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