Updated configrpc module to work with the new discovery component.

This commit is contained in:
Gunnar Beutner 2012-05-08 13:40:22 +02:00
parent 1573c19aaa
commit 22ad7b05dc
4 changed files with 28 additions and 7 deletions

View File

@ -28,9 +28,9 @@ void ConfigRpcComponent::Start(void)
m_ConfigRpcEndpoint->RegisterMethodSource("config::PropertyChanged");
}
m_ConfigRpcEndpoint->RegisterMethodHandler("message::Welcome",
bind_weak(&ConfigRpcComponent::WelcomeMessageHandler, shared_from_this()));
endpointManager->OnNewEndpoint += bind_weak(&ConfigRpcComponent::NewEndpointHandler, shared_from_this());
m_ConfigRpcEndpoint->RegisterMethodSource("config::FetchObjects");
m_ConfigRpcEndpoint->RegisterMethodHandler("config::ObjectCreated",
bind_weak(&ConfigRpcComponent::RemoteObjectUpdatedHandler, shared_from_this()));
m_ConfigRpcEndpoint->RegisterMethodHandler("config::ObjectRemoved",
@ -46,12 +46,20 @@ void ConfigRpcComponent::Stop(void)
// TODO: implement
}
int ConfigRpcComponent::WelcomeMessageHandler(const NewRequestEventArgs& ea)
int ConfigRpcComponent::NewEndpointHandler(const NewEndpointEventArgs& ea)
{
ea.Endpoint->OnSessionEstablished += bind_weak(&ConfigRpcComponent::SessionEstablishedHandler, shared_from_this());
return 0;
}
int ConfigRpcComponent::SessionEstablishedHandler(const EventArgs& ea)
{
JsonRpcRequest request;
request.SetMethod("config::FetchObjects");
GetEndpointManager()->SendUnicastRequest(m_ConfigRpcEndpoint, ea.Sender, request);
Endpoint::Ptr endpoint = static_pointer_cast<Endpoint>(ea.Source);
GetEndpointManager()->SendUnicastRequest(m_ConfigRpcEndpoint, endpoint, request);
return 0;
}

View File

@ -9,7 +9,8 @@ class ConfigRpcComponent : public IcingaComponent
private:
VirtualEndpoint::Ptr m_ConfigRpcEndpoint;
int WelcomeMessageHandler(const NewRequestEventArgs& ea);
int NewEndpointHandler(const NewEndpointEventArgs& ea);
int SessionEstablishedHandler(const EventArgs& ea);
int LocalObjectCreatedHandler(const EventArgs& ea);
int LocalObjectRemovedHandler(const EventArgs& ea);

View File

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<ClCompile Include="discoverycomponent.cpp" />
<ClCompile Include="discoverymessage.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="discoverycomponent.h" />
<ClInclude Include="i2-discovery.h" />
<ClInclude Include="discoverymessage.h" />
</ItemGroup>
</Project>

View File

@ -297,7 +297,7 @@ int DiscoveryComponent::WelcomeMessageHandler(const NewRequestEventArgs& nrea)
if (endpoint->GetSentWelcome()) {
EventArgs ea;
ea.Source = shared_from_this();
ea.Source = endpoint;
endpoint->OnSessionEstablished(ea);
}
@ -340,7 +340,7 @@ void DiscoveryComponent::FinishDiscoverySetup(Endpoint::Ptr endpoint)
if (endpoint->GetReceivedWelcome()) {
EventArgs ea;
ea.Source = shared_from_this();
ea.Source = endpoint;
endpoint->OnSessionEstablished(ea);
}
}