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