const RequestMessage& request)
{
Logger::Write(LogInformation, "demo", "Got 'hello world' from identity=" +
- sender->GetName());
+ (sender ? sender->GetName() : "(anonymous)"));
}
EXPORT_COMPONENT(demo, DemoComponent);
Endpoint::OnConnected.connect(boost::bind(&ReplicationComponent::EndpointConnectedHandler, this, _1));
m_Endpoint->RegisterTopicHandler("config::ObjectUpdate",
- boost::bind(&ReplicationComponent::RemoteObjectUpdateHandler, this, _2, _3));
+ boost::bind(&ReplicationComponent::RemoteObjectUpdateHandler, this, _3));
m_Endpoint->RegisterTopicHandler("config::ObjectRemoved",
boost::bind(&ReplicationComponent::RemoteObjectRemovedHandler, this, _3));
/* service status */
m_Endpoint->RegisterTopicHandler("checker::ServiceStateChange",
- boost::bind(&ReplicationComponent::ServiceStateChangeRequestHandler, _2, _3));
+ boost::bind(&ReplicationComponent::ServiceStateChangeRequestHandler, _3));
}
/**
m_Endpoint->Unregister();
}
-void ReplicationComponent::ServiceStateChangeRequestHandler(const Endpoint::Ptr& sender, const RequestMessage& request)
+void ReplicationComponent::ServiceStateChangeRequestHandler(const RequestMessage& request)
{
ServiceStateChangeMessage params;
if (!request.GetParams(¶ms))
}
}
-void ReplicationComponent::RemoteObjectUpdateHandler(const Endpoint::Ptr& sender, const RequestMessage& request)
+void ReplicationComponent::RemoteObjectUpdateHandler(const RequestMessage& request)
{
MessagePart params;
if (!request.GetParams(¶ms))
private:
Endpoint::Ptr m_Endpoint;
- static void ServiceStateChangeRequestHandler(const Endpoint::Ptr& sender, const RequestMessage& request);
+ static void ServiceStateChangeRequestHandler(const RequestMessage& request);
void EndpointConnectedHandler(const Endpoint::Ptr& endpoint);
void LocalObjectUnregisteredHandler(const DynamicObject::Ptr& object);
void TransactionClosingHandler(const set<DynamicObject::Ptr>& modifiedObjects);
- void RemoteObjectUpdateHandler(const Endpoint::Ptr& sender, const RequestMessage& request);
+ void RemoteObjectUpdateHandler(const RequestMessage& request);
void RemoteObjectRemovedHandler(const RequestMessage& request);
static RequestMessage MakeObjectMessage(const DynamicObject::Ptr& object,
m_PendingClients.erase(tlsStream);
}
+/**
+ * Sends an anonymous unicast message to the specified recipient.
+ *
+ * @param recipient The recipient of the message.
+ * @param message The message.
+ */
+void EndpointManager::SendUnicastMessage(const Endpoint::Ptr& recipient,
+ const MessagePart& message)
+{
+ SendUnicastMessage(Endpoint::Ptr(), recipient, message);
+}
+
/**
* Sends a unicast message to the specified recipient.
*
* @param sender The sender of the message.
* @param recipient The recipient of the message.
- * @param message The request.
+ * @param message The message.
*/
void EndpointManager::SendUnicastMessage(const Endpoint::Ptr& sender,
const Endpoint::Ptr& recipient, const MessagePart& message)
{
- /* don't forward messages between non-local endpoints */
- if (!sender->IsLocal() && !recipient->IsLocal())
+ /* don't forward messages between non-local endpoints, assume that
+ * anonymous senders (sender == null) are local */
+ if ((sender && !sender->IsLocal()) && !recipient->IsLocal())
return;
if (ResponseMessage::IsResponseMessage(message))
SendUnicastMessage(sender, recipient, message);
}
+/**
+ * Sends an anonymous message to all recipients who have a subscription for the
+ * message#s topic.
+ *
+ * @param message The message.
+ */
+void EndpointManager::SendMulticastMessage(const RequestMessage& message)
+{
+ SendMulticastMessage(Endpoint::Ptr(), message);
+}
+
/**
* Sends a message to all recipients who have a subscription for the
* message's topic.
void AddListener(const String& service);
void AddConnection(const String& node, const String& service);
+ void SendUnicastMessage(const Endpoint::Ptr& recipient, const MessagePart& message);
void SendUnicastMessage(const Endpoint::Ptr& sender, const Endpoint::Ptr& recipient, const MessagePart& message);
void SendAnycastMessage(const Endpoint::Ptr& sender, const RequestMessage& message);
+ void SendMulticastMessage(const RequestMessage& message);
void SendMulticastMessage(const Endpoint::Ptr& sender, const RequestMessage& message);
typedef function<void(const EndpointManager::Ptr&, const Endpoint::Ptr, const RequestMessage&, const ResponseMessage&, bool TimedOut)> APICallback;