2012-04-06 08:56:52 +02:00
|
|
|
#include "i2-icinga.h"
|
|
|
|
|
|
|
|
using namespace icinga;
|
|
|
|
|
2012-04-23 13:45:41 +02:00
|
|
|
string VirtualEndpoint::GetAddress(void) const
|
|
|
|
{
|
|
|
|
char address[50];
|
|
|
|
sprintf(address, "virtual:%p", this);
|
|
|
|
return address;
|
|
|
|
}
|
|
|
|
|
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)
|
2012-04-06 08:56:52 +02:00
|
|
|
{
|
|
|
|
m_MethodHandlers[method] += callback;
|
2012-04-16 16:27:41 +02:00
|
|
|
|
|
|
|
RegisterMethodSink(method);
|
2012-04-06 08:56:52 +02:00
|
|
|
}
|
|
|
|
|
2012-04-18 15:22:25 +02:00
|
|
|
void VirtualEndpoint::UnregisterMethodHandler(string method, function<int (const NewRequestEventArgs&)> callback)
|
2012-04-06 08:56:52 +02:00
|
|
|
{
|
|
|
|
// TODO: implement
|
2012-04-16 16:27:41 +02:00
|
|
|
//m_MethodHandlers[method] -= callback;
|
|
|
|
//UnregisterMethodSink(method);
|
2012-04-06 08:56:52 +02:00
|
|
|
|
2012-04-16 16:27:41 +02:00
|
|
|
throw NotImplementedException();
|
2012-04-06 08:56:52 +02:00
|
|
|
}
|
|
|
|
|
2012-04-18 15:22:25 +02:00
|
|
|
void VirtualEndpoint::ProcessRequest(Endpoint::Ptr sender, const JsonRpcRequest& request)
|
2012-04-06 08:56:52 +02:00
|
|
|
{
|
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())
|
2012-04-19 08:46:41 +02:00
|
|
|
return;
|
2012-04-16 16:27:41 +02:00
|
|
|
|
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-06 08:56:52 +02:00
|
|
|
}
|
|
|
|
|
2012-04-18 15:22:25 +02:00
|
|
|
void VirtualEndpoint::ProcessResponse(Endpoint::Ptr sender, const JsonRpcResponse& response)
|
2012-04-06 08:56:52 +02:00
|
|
|
{
|
2012-04-16 16:27:41 +02:00
|
|
|
// TODO: figure out which request this response belongs to and notify the caller
|
|
|
|
throw NotImplementedException();
|
2012-04-06 08:56:52 +02:00
|
|
|
}
|
2012-04-23 13:45:41 +02:00
|
|
|
|
|
|
|
void VirtualEndpoint::AddAllowedMethodSinkPrefix(string method)
|
|
|
|
{
|
|
|
|
/* Nothing to do here. */
|
|
|
|
}
|
|
|
|
|
|
|
|
void VirtualEndpoint::RemoveAllowedMethodSinkPrefix(string method)
|
|
|
|
{
|
|
|
|
/* Nothing to do here. */
|
|
|
|
}
|
|
|
|
|
|
|
|
void VirtualEndpoint::AddAllowedMethodSourcePrefix(string method)
|
|
|
|
{
|
|
|
|
/* Nothing to do here. */
|
|
|
|
}
|
|
|
|
|
|
|
|
void VirtualEndpoint::RemoveAllowedMethodSourcePrefix(string method)
|
|
|
|
{
|
|
|
|
/* Nothing to do here. */
|
|
|
|
}
|
|
|
|
|
|
|
|
bool VirtualEndpoint::IsAllowedMethodSink(string method) const
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool VirtualEndpoint::IsAllowedMethodSource(string method) const
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|