mirror of
https://github.com/Icinga/icinga2.git
synced 2025-06-19 05:00:24 +02:00
Bugfixes for the demo component.
This commit is contained in:
parent
d3798c4bf4
commit
ab0a37142a
@ -15,7 +15,7 @@ string DemoComponent::GetName(void) const
|
|||||||
void DemoComponent::Start(void)
|
void DemoComponent::Start(void)
|
||||||
{
|
{
|
||||||
m_DemoEndpoint = make_shared<VirtualEndpoint>();
|
m_DemoEndpoint = make_shared<VirtualEndpoint>();
|
||||||
m_DemoEndpoint->RegisterMethodSink("demo::HelloWorld");
|
m_DemoEndpoint->RegisterMethodHandler("demo::HelloWorld", bind_weak(&DemoComponent::HelloWorldRequestHAndler, shared_from_this()));
|
||||||
m_DemoEndpoint->RegisterMethodSource("demo::HelloWorld");
|
m_DemoEndpoint->RegisterMethodSource("demo::HelloWorld");
|
||||||
|
|
||||||
EndpointManager::Ptr endpointManager = GetIcingaApplication()->GetEndpointManager();
|
EndpointManager::Ptr endpointManager = GetIcingaApplication()->GetEndpointManager();
|
||||||
@ -32,14 +32,18 @@ void DemoComponent::Start(void)
|
|||||||
|
|
||||||
void DemoComponent::Stop(void)
|
void DemoComponent::Stop(void)
|
||||||
{
|
{
|
||||||
EndpointManager::Ptr endpointManager = GetIcingaApplication()->GetEndpointManager();
|
IcingaApplication::Ptr app = GetIcingaApplication();
|
||||||
endpointManager->UnregisterEndpoint(m_DemoEndpoint);
|
|
||||||
|
if (app) {
|
||||||
|
EndpointManager::Ptr endpointManager = app->GetEndpointManager();
|
||||||
|
endpointManager->UnregisterEndpoint(m_DemoEndpoint);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int AuthenticationComponent::NewEndpointHandler(const NewEndpointEventArgs& neea)
|
int DemoComponent::NewEndpointHandler(const NewEndpointEventArgs& neea)
|
||||||
{
|
{
|
||||||
neea.Endpoint->AddAllowedMethodSinkPrefix("demo");
|
neea.Endpoint->AddAllowedMethodSinkPrefix("demo::");
|
||||||
neea.Endpoint->AddAllowedMethodSourcePrefix("demo");
|
neea.Endpoint->AddAllowedMethodSourcePrefix("demo::");
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -49,19 +53,17 @@ int DemoComponent::DemoTimerHandler(const TimerEventArgs& tea)
|
|||||||
cout << "Sending multicast 'hello world' message." << endl;
|
cout << "Sending multicast 'hello world' message." << endl;
|
||||||
|
|
||||||
JsonRpcRequest request;
|
JsonRpcRequest request;
|
||||||
request.SetMethod("test");
|
request.SetMethod("demo::HelloWorld");
|
||||||
|
|
||||||
EndpointManager::Ptr endpointManager = GetIcingaApplication()->GetEndpointManager();
|
EndpointManager::Ptr endpointManager = GetIcingaApplication()->GetEndpointManager();
|
||||||
|
endpointManager->SendMulticastRequest(m_DemoEndpoint, request);
|
||||||
for (int i = 0; i < 5; i++)
|
|
||||||
endpointManager->SendMulticastRequest(m_DemoEndpoint, request);
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int DemoComponent::HelloWorldRequestHAndler(const NewRequestEventArgs& nrea)
|
int DemoComponent::HelloWorldRequestHAndler(const NewRequestEventArgs& nrea)
|
||||||
{
|
{
|
||||||
cout << "Got Hello World from " << nrea.Sender->GetAddress();
|
cout << "Got Hello World from " << nrea.Sender->GetAddress() << endl;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -19,6 +19,9 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "icinga", "icinga\icinga.vcx
|
|||||||
EndProject
|
EndProject
|
||||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "icinga-app", "icinga-app\icinga-app.vcxproj", "{BE412865-FEBA-4259-AD41-58950D1F5432}"
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "icinga-app", "icinga-app\icinga-app.vcxproj", "{BE412865-FEBA-4259-AD41-58950D1F5432}"
|
||||||
ProjectSection(ProjectDependencies) = postProject
|
ProjectSection(ProjectDependencies) = postProject
|
||||||
|
{2E6C1133-730F-4875-A72C-B455B1DD4C5C} = {2E6C1133-730F-4875-A72C-B455B1DD4C5C}
|
||||||
|
{697C6D7E-3109-484C-A7AF-384D28711610} = {697C6D7E-3109-484C-A7AF-384D28711610}
|
||||||
|
{E58F1DA7-B723-412B-B2B7-7FF58E2A944E} = {E58F1DA7-B723-412B-B2B7-7FF58E2A944E}
|
||||||
{C1FC77E1-04A4-481B-A78B-2F7AF489C2F8} = {C1FC77E1-04A4-481B-A78B-2F7AF489C2F8}
|
{C1FC77E1-04A4-481B-A78B-2F7AF489C2F8} = {C1FC77E1-04A4-481B-A78B-2F7AF489C2F8}
|
||||||
EndProjectSection
|
EndProjectSection
|
||||||
EndProject
|
EndProject
|
||||||
|
@ -29,7 +29,13 @@ void JsonRpcEndpoint::RemoveAllowedMethodSinkPrefix(string method)
|
|||||||
|
|
||||||
bool JsonRpcEndpoint::IsAllowedMethodSink(string method) const
|
bool JsonRpcEndpoint::IsAllowedMethodSink(string method) const
|
||||||
{
|
{
|
||||||
return (m_AllowedMethodSinkPrefixes.find(method) != m_AllowedMethodSinkPrefixes.end());
|
set<string>::iterator i;
|
||||||
|
for (i = m_AllowedMethodSinkPrefixes.begin(); i != m_AllowedMethodSinkPrefixes.end(); i++) {
|
||||||
|
if (method.compare(0, method.length(), method) == 0)
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void JsonRpcEndpoint::AddAllowedMethodSourcePrefix(string method)
|
void JsonRpcEndpoint::AddAllowedMethodSourcePrefix(string method)
|
||||||
@ -44,7 +50,13 @@ void JsonRpcEndpoint::RemoveAllowedMethodSourcePrefix(string method)
|
|||||||
|
|
||||||
bool JsonRpcEndpoint::IsAllowedMethodSource(string method) const
|
bool JsonRpcEndpoint::IsAllowedMethodSource(string method) const
|
||||||
{
|
{
|
||||||
return (m_AllowedMethodSourcePrefixes.find(method) != m_AllowedMethodSourcePrefixes.end());
|
set<string>::iterator i;
|
||||||
|
for (i = m_AllowedMethodSourcePrefixes.begin(); i != m_AllowedMethodSourcePrefixes.end(); i++) {
|
||||||
|
if (method.compare(0, method.length(), method) == 0)
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void JsonRpcEndpoint::Connect(string host, unsigned short port)
|
void JsonRpcEndpoint::Connect(string host, unsigned short port)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user