{
Endpoint::Ptr endpoint = nrea.Sender;
- if (endpoint->GetHandshakeCounter() >= 2)
+ if (endpoint->GetReceivedWelcome())
return 0;
- endpoint->IncrementHandshakeCounter();
+ endpoint->SetReceivedWelcome(true);
- if (endpoint->GetHandshakeCounter() >= 2) {
+ if (endpoint->GetSentWelcome()) {
EventArgs ea;
ea.Source = shared_from_this();
endpoint->OnSessionEstablished(ea);
void DiscoveryComponent::FinishDiscoverySetup(Endpoint::Ptr endpoint)
{
- if (endpoint->GetHandshakeCounter() >= 2)
+ if (endpoint->GetSentWelcome())
return;
// we assume the other component _always_ wants
request.SetMethod("discovery::Welcome");
GetEndpointManager()->SendUnicastRequest(m_DiscoveryEndpoint, endpoint, request);
+ endpoint->SetSentWelcome(true);
+
ComponentDiscoveryInfo::Ptr info;
if (GetComponentDiscoveryInfo(endpoint->GetIdentity(), &info)) {
endpoint->RegisterMethodSink(*i);
}
- endpoint->IncrementHandshakeCounter();
-
- if (endpoint->GetHandshakeCounter() >= 2) {
+ if (endpoint->GetReceivedWelcome()) {
EventArgs ea;
ea.Source = shared_from_this();
endpoint->OnSessionEstablished(ea);
/* update LastSeen if we're still connected to this endpoint */
info->LastSeen = now;
} else {
+ /* TODO: figure out whether we actually want to connect to this component (_always_ if IsBroker() == true) */
/* try and reconnect to this component */
endpointManager->AddConnection(info->Node, info->Service);
}
"kekslistener": { "replicate": "0", "service": "8888" }
},
"broker": {
- "icinga-c1": { "replicate": "0", "node": "127.0.0.1", "service": "7777" }
+ "icinga-c1": { "replicate": "0", "node": "10.0.10.3", "service": "7777" }
}
}
\ No newline at end of file
Endpoint::Endpoint(void)
{
- m_HandshakeCounter = false;
+ m_ReceivedWelcome = false;
+ m_SentWelcome = false;
}
string Endpoint::GetIdentity(void) const
return m_MethodSources.end();
}
-void Endpoint::IncrementHandshakeCounter(void)
+void Endpoint::SetReceivedWelcome(bool value)
{
- m_HandshakeCounter++;
+ m_ReceivedWelcome = value;
}
-unsigned short Endpoint::GetHandshakeCounter(void) const
+bool Endpoint::GetReceivedWelcome(void) const
{
- return m_HandshakeCounter;
+ return m_ReceivedWelcome;
}
+
+void Endpoint::SetSentWelcome(bool value)
+{
+ m_SentWelcome = value;
+}
+
+bool Endpoint::GetSentWelcome(void) const
+{
+ return m_SentWelcome;
+}
\ No newline at end of file
string m_Identity;
set<string> m_MethodSinks;
set<string> m_MethodSources;
- unsigned short m_HandshakeCounter;
+ bool m_ReceivedWelcome;
+ bool m_SentWelcome;
weak_ptr<EndpointManager> m_EndpointManager;
void SetIdentity(string identity);
bool HasIdentity(void) const;
- void IncrementHandshakeCounter();
- unsigned short GetHandshakeCounter(void) const;
+ void SetReceivedWelcome(bool value);
+ bool GetReceivedWelcome(void) const;
+
+ void SetSentWelcome(bool value);
+ bool GetSentWelcome(void) const;
shared_ptr<EndpointManager> GetEndpointManager(void) const;
void SetEndpointManager(weak_ptr<EndpointManager> manager);