Skip to content

Commit

Permalink
Clearly document lifetime expectations for CommandSender. (#7067)
Browse files Browse the repository at this point in the history
  • Loading branch information
bzbarsky-apple authored May 25, 2021
1 parent f95637b commit 0d14370
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
11 changes: 10 additions & 1 deletion src/app/CommandSender.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,22 @@ class CommandSender : public Command, public Messaging::ExchangeDelegate
{
public:
// TODO: issue #6792 - the secure session parameter should be made non-optional and passed by reference.
// Once SendCommandRequest returns successfully, the CommandSender will
// handle calling Shutdown on itself once it decides it's done with waiting
// for a response (i.e. times out or gets a response).
//
// If SendCommandRequest is never called, or the call fails, the API
// consumer is responsible for calling Shutdown on the CommandSender.
CHIP_ERROR SendCommandRequest(NodeId aNodeId, Transport::AdminId aAdminId, SecureSessionHandle * secureSession = nullptr);

private:
// ExchangeDelegate interface implementation. Private so people won't
// accidentally call it on us when we're not being treated as an actual
// ExchangeDelegate.
void OnMessageReceived(Messaging::ExchangeContext * apExchangeContext, const PacketHeader & aPacketHeader,
const PayloadHeader & aPayloadHeader, System::PacketBufferHandle && aPayload) override;
void OnResponseTimeout(Messaging::ExchangeContext * apExchangeContext) override;

private:
CHIP_ERROR ProcessCommandDataElement(CommandDataElement::Parser & aCommandElement) override;
};

Expand Down
2 changes: 1 addition & 1 deletion src/app/InteractionModelEngine.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ class InteractionModelEngine : public Messaging::ExchangeDelegate

/**
* Retrieve a CommandSender that the SDK consumer can use to send a set of commands. If the call succeeds,
* the consumer is responsible for calling Shutdown() on the CommandSender once it's done using it.
* see CommandSender documentation for lifetime handling.
*
* @param[out] apCommandSender A pointer to the CommandSender object.
*
Expand Down

0 comments on commit 0d14370

Please sign in to comment.