2012-04-06 08:56:52 +02:00
|
|
|
#ifndef VIRTUALENDPOINT_H
|
|
|
|
#define VIRTUALENDPOINT_H
|
|
|
|
|
|
|
|
namespace icinga
|
|
|
|
{
|
|
|
|
|
2012-04-16 16:27:41 +02:00
|
|
|
struct I2_JSONRPC_API NewRequestEventArgs : public EventArgs
|
|
|
|
{
|
|
|
|
typedef shared_ptr<NewRequestEventArgs> Ptr;
|
|
|
|
typedef weak_ptr<NewRequestEventArgs> WeakPtr;
|
|
|
|
|
|
|
|
Endpoint::Ptr Sender;
|
|
|
|
JsonRpcRequest::Ptr Request;
|
|
|
|
};
|
|
|
|
|
2012-04-06 08:56:52 +02:00
|
|
|
class I2_ICINGA_API VirtualEndpoint : public Endpoint
|
|
|
|
{
|
|
|
|
private:
|
2012-04-16 16:27:41 +02:00
|
|
|
map< string, Event<NewRequestEventArgs::Ptr> > m_MethodHandlers;
|
2012-04-06 08:56:52 +02:00
|
|
|
|
|
|
|
public:
|
|
|
|
typedef shared_ptr<VirtualEndpoint> Ptr;
|
|
|
|
typedef weak_ptr<VirtualEndpoint> WeakPtr;
|
|
|
|
|
2012-04-16 16:27:41 +02:00
|
|
|
void RegisterMethodHandler(string method, function<int (NewRequestEventArgs::Ptr)> callback);
|
|
|
|
void UnregisterMethodHandler(string method, function<int (NewRequestEventArgs::Ptr)> callback);
|
2012-04-06 08:56:52 +02:00
|
|
|
|
|
|
|
virtual void RegisterMethodSource(string method);
|
|
|
|
virtual void UnregisterMethodSource(string method);
|
|
|
|
|
2012-04-16 16:27:41 +02:00
|
|
|
virtual void SendRequest(Endpoint::Ptr sender, JsonRpcRequest::Ptr message);
|
|
|
|
virtual void SendResponse(Endpoint::Ptr sender, JsonRpcResponse::Ptr message);
|
2012-04-06 08:56:52 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif /* VIRTUALENDPOINT_H */
|