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