feat: possibility to get node id of the unsolicited message sender (#33704)
diff --git a/src/messaging/ExchangeDelegate.h b/src/messaging/ExchangeDelegate.h
index 97a5a0a..cf2eea8 100644
--- a/src/messaging/ExchangeDelegate.h
+++ b/src/messaging/ExchangeDelegate.h
@@ -140,7 +140,7 @@
/**
* @brief
* This class handles unsolicited messages. The implementation can select an exchange delegate to use based on the payload header
- * of the incoming message.
+ * of the incoming message or its session.
*/
class DLL_EXPORT UnsolicitedMessageHandler
{
@@ -158,9 +158,19 @@
*
* @param[in] payloadHeader A reference to the PayloadHeader object for the unsolicited message. The protocol and message
* type of this header match the UnsolicitedMessageHandler.
+ * @param[in] session A reference to the session where unsolicited message was received.
* @param[out] newDelegate A new exchange delegate to be used by the new exchange created to handle the message.
*/
- virtual CHIP_ERROR OnUnsolicitedMessageReceived(const PayloadHeader & payloadHeader, ExchangeDelegate *& newDelegate) = 0;
+ virtual CHIP_ERROR OnUnsolicitedMessageReceived(const PayloadHeader & payloadHeader, const SessionHandle & session,
+ ExchangeDelegate *& newDelegate)
+ {
+ return OnUnsolicitedMessageReceived(payloadHeader, newDelegate);
+ }
+
+ virtual CHIP_ERROR OnUnsolicitedMessageReceived(const PayloadHeader & payloadHeader, ExchangeDelegate *& newDelegate)
+ {
+ return CHIP_ERROR_NOT_IMPLEMENTED;
+ }
/**
* @brief
diff --git a/src/messaging/ExchangeMgr.cpp b/src/messaging/ExchangeMgr.cpp
index c60b948..bf92fa2 100644
--- a/src/messaging/ExchangeMgr.cpp
+++ b/src/messaging/ExchangeMgr.cpp
@@ -320,7 +320,7 @@
ExchangeDelegate * delegate = nullptr;
// Fetch delegate from the handler
- CHIP_ERROR err = matchingUMH->Handler->OnUnsolicitedMessageReceived(payloadHeader, delegate);
+ CHIP_ERROR err = matchingUMH->Handler->OnUnsolicitedMessageReceived(payloadHeader, session, delegate);
if (err != CHIP_NO_ERROR)
{
// Using same error message for all errors to reduce code size.