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