lmessage->Set("method", "log::SetLogPosition");
lmessage->Set("params", lparams);
- BOOST_FOREACH(const JsonRpcConnection::Ptr& client, endpoint->GetClients())
- client->SendMessage(lmessage);
+ double maxTs = 0;
+
+ BOOST_FOREACH(const JsonRpcConnection::Ptr& client, endpoint->GetClients()) {
+ if (client->GetTimestamp() > maxTs)
+ maxTs = client->GetTimestamp();
+ }
+
+ BOOST_FOREACH(const JsonRpcConnection::Ptr& client, endpoint->GetClients()) {
+ if (client->GetTimestamp() != maxTs)
+ client->Disconnect();
+ else
+ client->SendMessage(lmessage);
+ }
Log(LogNotice, "ApiListener")
<< "Setting log position for identity '" << endpoint->GetName() << "': "
Log(LogNotice, "ApiListener")
<< "Sending message to '" << endpoint->GetName() << "'";
- BOOST_FOREACH(const JsonRpcConnection::Ptr& client, endpoint->GetClients())
+ double maxTs = 0;
+
+ BOOST_FOREACH(const JsonRpcConnection::Ptr& client, endpoint->GetClients()) {
+ if (client->GetTimestamp() > maxTs)
+ maxTs = client->GetTimestamp();
+ }
+
+ BOOST_FOREACH(const JsonRpcConnection::Ptr& client, endpoint->GetClients()) {
+ if (client->GetTimestamp() != maxTs)
+ continue;
+
client->SendMessage(message);
+ }
}
}
JsonRpcConnection::JsonRpcConnection(const String& identity, bool authenticated,
const TlsStream::Ptr& stream, ConnectionRole role)
: m_Identity(identity), m_Authenticated(authenticated), m_Stream(stream),
- m_Role(role), m_Seen(Utility::GetTime()),
+ m_Role(role), m_Timestamp(Utility::GetTime()), m_Seen(Utility::GetTime()),
m_NextHeartbeat(0), m_HeartbeatTimeout(0)
{
boost::call_once(l_JsonRpcConnectionOnceFlag, &JsonRpcConnection::StaticInitialize);
DataAvailableHandler();
}
+double JsonRpcConnection::GetTimestamp(void) const
+{
+ return m_Timestamp;
+}
+
String JsonRpcConnection::GetIdentity(void) const
{
return m_Identity;
void Start(void);
+ double GetTimestamp(void) const;
String GetIdentity(void) const;
bool IsAuthenticated(void) const;
Endpoint::Ptr GetEndpoint(void) const;
Endpoint::Ptr m_Endpoint;
TlsStream::Ptr m_Stream;
ConnectionRole m_Role;
+ double m_Timestamp;
double m_Seen;
double m_NextHeartbeat;
double m_HeartbeatTimeout;