@@ -594,21 +594,26 @@ CHIP_ERROR ExchangeContext::HandleMessage(uint32_t messageCounter, const Payload
594
594
// Set kFlagReceivedAtLeastOneMessage to true since we have received at least one new application level message
595
595
SetHasReceivedAtLeastOneMessage (true );
596
596
597
- if (IsResponseExpected ())
597
+ // Don't send messages on to our delegate if our dispatch does not allow
598
+ // those messages. Those messages should also not be treated as responses,
599
+ // since if our delegate is expecting a response we will not notify it about
600
+ // these messages.
601
+ if (mDispatch .MessagePermitted (payloadHeader.GetProtocolID (), payloadHeader.GetMessageType ()))
598
602
{
599
- // Since we got the response, cancel the response timer.
600
- CancelResponseTimer ();
603
+ if (IsResponseExpected ())
604
+ {
605
+ // Since we got the response, cancel the response timer.
606
+ CancelResponseTimer ();
601
607
602
- // If the context was expecting a response to a previously sent message, this message
603
- // is implicitly that response.
604
- SetResponseExpected (false );
605
- }
608
+ // If the context was expecting a response to a previously sent message, this message
609
+ // is implicitly that response.
610
+ SetResponseExpected (false );
611
+ }
606
612
607
- // Don't send messages on to our delegate if our dispatch does not allow
608
- // those messages.
609
- if (mDelegate != nullptr && mDispatch .MessagePermitted (payloadHeader.GetProtocolID (), payloadHeader.GetMessageType ()))
610
- {
611
- return mDelegate ->OnMessageReceived (this , payloadHeader, std::move (msgBuf));
613
+ if (mDelegate != nullptr )
614
+ {
615
+ return mDelegate ->OnMessageReceived (this , payloadHeader, std::move (msgBuf));
616
+ }
612
617
}
613
618
614
619
DefaultOnMessageReceived (this , payloadHeader.GetProtocolID (), payloadHeader.GetMessageType (), messageCounter,
0 commit comments