nl:: Weave:: ExchangeContext
#include <src/lib/core/WeaveExchangeMgr.h>
This class represents an ongoing conversation (ExchangeContext) between two or more nodes.
Summary
It defines methods for encoding and communicating Weave messages within an ExchangeContext over various transport mechanisms, for example, TCP, UDP, or Weave Reliable Messaging.
Public types |
|
---|---|
@34{
|
enum |
@35{
|
enum |
ConnectionClosedFunct)(ExchangeContext *ec, WeaveConnection *con, WEAVE_ERROR conErr)
|
typedefvoid(*
This function is the application callback to invoke when an existing Weave connection has been closed. |
KeyErrorFunct)(ExchangeContext *ec, WEAVE_ERROR keyErr)
|
typedefvoid(*
Type of key error message handling function. |
MessageReceiveFunct)(ExchangeContext *ec, const IPPacketInfo *pktInfo, const WeaveMessageInfo *msgInfo, uint32_t profileId, uint8_t msgType, PacketBuffer *payload)
|
typedefvoid(*
This function is the application callback for handling a received Weave message. |
ResponseTimeoutFunct)(ExchangeContext *ec)
|
typedefvoid(*
This function is the application callback to invoke when the timeout for the receipt of a response message has expired. |
RetransmissionTimeoutFunct)(ExchangeContext *ec)
|
typedefvoid(*
This function is the application callback to invoke when the timeout for the retransmission of a previously sent message has expired. |
Timeout
|
typedefuint32_t
Type used to express the timeout in this ExchangeContext, in milliseconds. |
WRMPAckRcvdFunct)(ExchangeContext *ec, void *msgCtxt)
|
typedefvoid(*
This function is the application callback to invoke when an Acknowledgment is received for a Weave message that requested one as part of the Weave Reliable Messaging Protocol. |
WRMPPauseRcvdFunct)(ExchangeContext *ec, uint32_t pauseTime)
|
typedefvoid(*
This function is the application callback to invoke when a Throttle message or Delayed Delivery message is received as part of the Weave Reliable Messaging Protocol. |
WRMPSendErrorFunct)(ExchangeContext *ec, WEAVE_ERROR err, void *msgCtxt)
|
typedefvoid(*
This function is the application callback to invoke when an error is encountered while sending a Weave message. |
Public attributes |
|
---|---|
AllowDuplicateMsgs
|
bool
Boolean indicator of whether duplicate messages are allowed for a given exchange.
|
AppState
|
void *
Pointer to application-specific state object.
|
Con
|
[READ ONLY] Associated Weave connection.
|
EncryptionType
|
uint8_t
Encryption type to use when sending a message.
|
ExchangeId
|
uint16_t
[READ ONLY] Assigned exchange ID.
|
ExchangeMgr
|
[READ ONLY] Owning exchange manager.
|
KeyId
|
uint16_t
Encryption key to use when sending a message.
|
OnAckRcvd
|
Application callback for received acknowledgment.
|
OnConnectionClosed
|
|
OnDDRcvd
|
Application callback for received Delayed Delivery message.
|
OnKeyError
|
This function is the application callback to invoke when key error message has been received from the peer.
|
OnMessageReceived
|
|
OnResponseTimeout
|
|
OnRetransmissionTimeout
|
|
OnSendError
|
Application callback for error while sending.
|
OnThrottleRcvd
|
Application callback for received Throttle message.
|
PeerAddr
|
IPAddress
[READ ONLY] IP address of peer node.
|
PeerIntf
|
InterfaceId
[READ ONLY] Outbound interface to be used when sending messages to the peer.
|
PeerNodeId
|
uint64_t
[READ ONLY] Node ID of peer node.
|
PeerPort
|
uint16_t
[READ ONLY] Port of peer node.
|
ResponseTimeout
|
Maximum time to wait for response (in milliseconds); 0 disables response timeout.
|
RetransInterval
|
uint32_t
Time between retransmissions (in milliseconds); 0 disables retransmissions.
|
mMsgProtocolVersion
|
uint16_t
Message Protocol version for the ExchangeContext.
|
mWRMPConfig
|
WRMP configuration.
|
Public functions |
|
---|---|
Abort(void)
|
void
Abort the Exchange context immediately and release all references to it.
|
AddRef(void)
|
void
Increment the reference counter for the exchange context by one.
|
AutoRequestAck() const
|
bool
Returns whether an acknowledgment will be requested whenever a message is sent.
|
CancelRetrans(void)
|
void
Cancel the Trickle retransmission mechanism.
|
Close(void)
|
void
Gracefully close an exchange context.
|
EncodeExchHeader(WeaveExchangeHeader *exchangeHeader, uint32_t profileId, uint8_t msgType, PacketBuffer *msgBuf, uint16_t sendFlags)
|
Encode the exchange header into a message buffer.
|
GetAutoReleaseKey() const
|
bool
Return whether the encryption key associated with the exchange should be released when the exchange is freed.
|
GetCurrentRetransmitTimeout(void)
|
uint32_t
Get the current retransmit timeout.
|
GetPeerDescription(char *buf, uint32_t bufSize) const
|
void
Constructs a string describing the peer node and its associated address / connection information.
|
HandleTrickleMessage(const IPPacketInfo *pktInfo, const WeaveMessageInfo *msgInfo)
|
void
Handle trickle message within the exchange context.
|
HasPeerRequestedAck(void) const
|
bool
Determine whether peer requested acknowledgment for at least one message on this exchange.
|
HasRcvdMsgFromPeer(void) const
|
bool
Determine whether at least one message has been received on this exchange from peer.
|
IsAckPending(void) const
|
bool
Determine whether there is already an acknowledgment pending to be sent to the peer on this exchange.
|
IsConnectionClosed(void) const
|
bool
Determine whether the ExchangeContext has an associated active WeaveConnection.
|
IsInitiator(void) const
|
bool
Determine whether the context is the initiator of the exchange.
|
IsResponseExpected(void) const
|
bool
Determine whether a response is expected for messages sent over this exchange.
|
Release(void)
|
void
Release reference to this exchange context.
|
SendCommonNullMessage(void)
|
Send a Common::Null message.
|
SendMessage(uint32_t profileId, uint8_t msgType, PacketBuffer *msgPayload, uint16_t sendFlags, void *msgCtxt)
|
Send a Weave message on this exchange.
|
SendMessage(uint32_t profileId, uint8_t msgType, PacketBuffer *msgBuf, uint16_t sendFlags, WeaveMessageInfo *msgInfo, void *msgCtxt)
|
Send a Weave message on this exchange.
|
SetAckPending(bool inAckPending)
|
void
Set if an acknowledgment needs to be sent back to the peer on this exchange.
|
SetAutoReleaseKey(bool autoReleaseKey)
|
void
Set whether the encryption key associated with the exchange should be released when the exchange is freed.
|
SetAutoRequestAck(bool autoReqAck)
|
void
Set whether an acknowledgment should be requested whenever a message is sent.
|
SetConnectionClosed(bool inConnectionClosed)
|
void
Set the kFlagConnectionClosed flag bit.
|
SetDropAck(bool inDropAck)
|
void
Set whether the WeaveExchangeManager should not send acknowledgements for this context.
|
SetInitiator(bool inInitiator)
|
void
Set the kFlagInitiator flag bit.
|
SetMsgRcvdFromPeer(bool inMsgRcvdFromPeer)
|
void
Set if a message has been received from the peer on this exchange.
|
SetPeerRequestedAck(bool inPeerRequestedAck)
|
void
Set if an acknowledgment was requested in the last message received on this exchange.
|
SetResponseExpected(bool inResponseExpected)
|
void
Set whether a response is expected on this exchange.
|
SetShouldAutoReleaseConnection(bool autoReleaseCon)
|
void
Set whether the Weave connection associated with the exchange should be released when the exchange is freed.
|
SetupTrickleRetransmit(uint32_t retransInterval, uint8_t threshold, uint32_t timeout)
|
Setup the trickle retransmission mechanism by setting the corresponding retransmission interval and rebroadcast threshold.
|
ShouldAutoReleaseConnection() const
|
bool
Return whether the Weave connection associated with the exchange should be released when the exchange is freed.
|
ShouldDropAck(void) const
|
bool
Determine whether the WeaveExchangeManager should not send an acknowledgement.
|
StartTimerT(void)
|
Start the Trickle rebroadcast algorithm's periodic retransmission timer mechanism.
|
TeardownTrickleRetransmit(void)
|
void
Tear down the Trickle retransmission mechanism by canceling the periodic timers within Trickle and freeing the message buffer holding the Weave message.
|
UseEphemeralUDPPort(void) const
|
bool
Return whether outbound messages sent via the exchange should be sent from the local ephemeral UDP port.
|
WRMPFlushAcks(void)
|
|
WRMPSendDelayedDelivery(uint32_t PauseTimeMillis, uint64_t DelayedNodeId)
|
Send a Delayed Delivery message to notify a sender node that its previously sent message would experience an expected delay before being delivered to the recipient.
|
WRMPSendThrottleFlow(uint32_t PauseTimeMillis)
|
Send a Throttle Flow message to the peer node requesting it to throttle its sending of messages.
|
Public types
@34
@34
@35
@35
Properties | |
---|---|
kGetPeerDescription_MaxLength
|
Maximum length of string (including NUL character) returned by GetPeerDescription(). |
ConnectionClosedFunct
void(* ConnectionClosedFunct)(ExchangeContext *ec, WeaveConnection *con, WEAVE_ERROR conErr)
This function is the application callback to invoke when an existing Weave connection has been closed.
Details | |||||||
---|---|---|---|---|---|---|---|
Parameters |
|
KeyErrorFunct
void(* KeyErrorFunct)(ExchangeContext *ec, WEAVE_ERROR keyErr)
Type of key error message handling function.
Details | |||||
---|---|---|---|---|---|
Parameters |
|
MessageReceiveFunct
void(* MessageReceiveFunct)(ExchangeContext *ec, const IPPacketInfo *pktInfo, const WeaveMessageInfo *msgInfo, uint32_t profileId, uint8_t msgType, PacketBuffer *payload)
This function is the application callback for handling a received Weave message.
Details | |||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Parameters |
|
ResponseTimeoutFunct
void(* ResponseTimeoutFunct)(ExchangeContext *ec)
This function is the application callback to invoke when the timeout for the receipt of a response message has expired.
Details | |||
---|---|---|---|
Parameters |
|
RetransmissionTimeoutFunct
void(* RetransmissionTimeoutFunct)(ExchangeContext *ec)
This function is the application callback to invoke when the timeout for the retransmission of a previously sent message has expired.
Details | |||
---|---|---|---|
Parameters |
|
WRMPAckRcvdFunct
void(* WRMPAckRcvdFunct)(ExchangeContext *ec, void *msgCtxt)
This function is the application callback to invoke when an Acknowledgment is received for a Weave message that requested one as part of the Weave Reliable Messaging Protocol.
Details | |||||
---|---|---|---|---|---|
Parameters |
|
WRMPPauseRcvdFunct
void(* WRMPPauseRcvdFunct)(ExchangeContext *ec, uint32_t pauseTime)
This function is the application callback to invoke when a Throttle message or Delayed Delivery message is received as part of the Weave Reliable Messaging Protocol.
Each of these messages are accompanied with a time value (in milliseconds) that signifies the time to pause sending of Weave messages on this ExchangeContext.
Details | |||||
---|---|---|---|---|---|
Parameters |
|
WRMPSendErrorFunct
void(* WRMPSendErrorFunct)(ExchangeContext *ec, WEAVE_ERROR err, void *msgCtxt)
This function is the application callback to invoke when an error is encountered while sending a Weave message.
Details | |||||||
---|---|---|---|---|---|---|---|
Parameters |
|
Public attributes
AllowDuplicateMsgs
bool AllowDuplicateMsgs
Boolean indicator of whether duplicate messages are allowed for a given exchange.
AppState
void * AppState
Pointer to application-specific state object.
EncryptionType
uint8_t EncryptionType
Encryption type to use when sending a message.
ExchangeId
uint16_t ExchangeId
[READ ONLY] Assigned exchange ID.
KeyId
uint16_t KeyId
Encryption key to use when sending a message.
OnConnectionClosed
ConnectionClosedFunct OnConnectionClosed
OnKeyError
KeyErrorFunct OnKeyError
This function is the application callback to invoke when key error message has been received from the peer.
OnMessageReceived
MessageReceiveFunct OnMessageReceived
OnResponseTimeout
ResponseTimeoutFunct OnResponseTimeout
OnRetransmissionTimeout
RetransmissionTimeoutFunct OnRetransmissionTimeout
OnThrottleRcvd
WRMPPauseRcvdFunct OnThrottleRcvd
Application callback for received Throttle message.
PeerAddr
IPAddress PeerAddr
[READ ONLY] IP address of peer node.
PeerIntf
InterfaceId PeerIntf
[READ ONLY] Outbound interface to be used when sending messages to the peer.
(Only meaningful for UDP.)
PeerNodeId
uint64_t PeerNodeId
[READ ONLY] Node ID of peer node.
PeerPort
uint16_t PeerPort
[READ ONLY] Port of peer node.
ResponseTimeout
Timeout ResponseTimeout
Maximum time to wait for response (in milliseconds); 0 disables response timeout.
RetransInterval
uint32_t RetransInterval
Time between retransmissions (in milliseconds); 0 disables retransmissions.
Public functions
Abort
void Abort( void )
Abort the Exchange context immediately and release all references to it.
AddRef
void AddRef( void )
Increment the reference counter for the exchange context by one.
AutoRequestAck
bool AutoRequestAck() const
Returns whether an acknowledgment will be requested whenever a message is sent.
CancelRetrans
void CancelRetrans( void )
Cancel the Trickle retransmission mechanism.
Close
void Close( void )
Gracefully close an exchange context.
This call decrements the reference count and releases the exchange when the reference count goes to zero.
EncodeExchHeader
WEAVE_ERROR EncodeExchHeader( WeaveExchangeHeader *exchangeHeader, uint32_t profileId, uint8_t msgType, PacketBuffer *msgBuf, uint16_t sendFlags )
Encode the exchange header into a message buffer.
Details | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Parameters |
|
||||||||||
Return Values |
|
GetAutoReleaseKey
bool GetAutoReleaseKey() const
Return whether the encryption key associated with the exchange should be released when the exchange is freed.
GetCurrentRetransmitTimeout
uint32_t GetCurrentRetransmitTimeout( void )
Get the current retransmit timeout.
It would be either the initial or the active retransmit timeout based on whether the ExchangeContext has an active message exchange going with its peer.
Details | |
---|---|
Returns |
the current retransmit time.
|
GetPeerDescription
void GetPeerDescription( char *buf, uint32_t bufSize ) const
Constructs a string describing the peer node and its associated address / connection information.
Details | |||||
---|---|---|---|---|---|
Parameters |
|
HandleTrickleMessage
void HandleTrickleMessage( const IPPacketInfo *pktInfo, const WeaveMessageInfo *msgInfo )
Handle trickle message within the exchange context.
Details | |||||
---|---|---|---|---|---|
Parameters |
|
HasPeerRequestedAck
bool HasPeerRequestedAck( void ) const
Determine whether peer requested acknowledgment for at least one message on this exchange.
Details | |
---|---|
Returns |
Returns 'true' if acknowledgment requested, else 'false'.
|
HasRcvdMsgFromPeer
bool HasRcvdMsgFromPeer( void ) const
Determine whether at least one message has been received on this exchange from peer.
Details | |
---|---|
Returns |
Returns 'true' if message received, else 'false'.
|
IsAckPending
bool IsAckPending( void ) const
Determine whether there is already an acknowledgment pending to be sent to the peer on this exchange.
IsConnectionClosed
bool IsConnectionClosed( void ) const
Determine whether the ExchangeContext has an associated active WeaveConnection.
Details | |
---|---|
Returns |
Returns 'true' if connection is closed, else 'false'.
|
IsInitiator
bool IsInitiator( void ) const
Determine whether the context is the initiator of the exchange.
Details | |
---|---|
Returns |
Returns 'true' if it is the initiator, else 'false'.
|
IsResponseExpected
bool IsResponseExpected( void ) const
Determine whether a response is expected for messages sent over this exchange.
Details | |
---|---|
Returns |
Returns 'true' if response expected, else 'false'.
|
Release
void Release( void )
Release reference to this exchange context.
If count is down to one then close the context, reset all application callbacks, and stop all timers.
SendCommonNullMessage
WEAVE_ERROR SendCommonNullMessage( void )
Send a Common::Null message.
Details | |||||||
---|---|---|---|---|---|---|---|
Return Values |
|
SendMessage
WEAVE_ERROR SendMessage( uint32_t profileId, uint8_t msgType, PacketBuffer *msgPayload, uint16_t sendFlags, void *msgCtxt )
Send a Weave message on this exchange.
Details | |||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Parameters |
|
||||||||||||
Return Values |
|
SendMessage
WEAVE_ERROR SendMessage( uint32_t profileId, uint8_t msgType, PacketBuffer *msgBuf, uint16_t sendFlags, WeaveMessageInfo *msgInfo, void *msgCtxt )
Send a Weave message on this exchange.
Details | |||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Parameters |
|
||||||||||||
Return Values |
|
SetAckPending
void SetAckPending( bool inAckPending )
Set if an acknowledgment needs to be sent back to the peer on this exchange.
Details | |||
---|---|---|---|
Parameters |
|
SetAutoReleaseKey
void SetAutoReleaseKey( bool autoReleaseKey )
Set whether the encryption key associated with the exchange should be released when the exchange is freed.
Details | |||
---|---|---|---|
Parameters |
|
SetAutoRequestAck
void SetAutoRequestAck( bool autoReqAck )
Set whether an acknowledgment should be requested whenever a message is sent.
Details | |||
---|---|---|---|
Parameters |
|
SetConnectionClosed
void SetConnectionClosed( bool inConnectionClosed )
Set the kFlagConnectionClosed flag bit.
This flag is set when a WeaveConnection associated with an ExchangeContext is closed.
Details | |||
---|---|---|---|
Parameters |
|
SetDropAck
void SetDropAck( bool inDropAck )
Set whether the WeaveExchangeManager should not send acknowledgements for this context.
For internal, debug use only.
Details | |||
---|---|---|---|
Parameters |
|
SetInitiator
void SetInitiator( bool inInitiator )
Set the kFlagInitiator flag bit.
This flag is set by the node that initiates an exchange.
Details | |||
---|---|---|---|
Parameters |
|
SetMsgRcvdFromPeer
void SetMsgRcvdFromPeer( bool inMsgRcvdFromPeer )
Set if a message has been received from the peer on this exchange.
Details | |||
---|---|---|---|
Parameters |
|
SetPeerRequestedAck
void SetPeerRequestedAck( bool inPeerRequestedAck )
Set if an acknowledgment was requested in the last message received on this exchange.
Details | |||
---|---|---|---|
Parameters |
|
SetResponseExpected
void SetResponseExpected( bool inResponseExpected )
Set whether a response is expected on this exchange.
Details | |||
---|---|---|---|
Parameters |
|
SetShouldAutoReleaseConnection
void SetShouldAutoReleaseConnection( bool autoReleaseCon )
Set whether the Weave connection associated with the exchange should be released when the exchange is freed.
Details | |||
---|---|---|---|
Parameters |
|
SetupTrickleRetransmit
WEAVE_ERROR SetupTrickleRetransmit( uint32_t retransInterval, uint8_t threshold, uint32_t timeout )
Setup the trickle retransmission mechanism by setting the corresponding retransmission interval and rebroadcast threshold.
Details | |||||||
---|---|---|---|---|---|---|---|
Parameters |
|
||||||
Returns |
WEAVE_NO_ERROR if Trickle setup was successful, else an INET_ERROR mapped into a WEAVE_ERROR.
|
ShouldAutoReleaseConnection
bool ShouldAutoReleaseConnection() const
Return whether the Weave connection associated with the exchange should be released when the exchange is freed.
ShouldDropAck
bool ShouldDropAck( void ) const
Determine whether the WeaveExchangeManager should not send an acknowledgement.
For internal, debug use only.
StartTimerT
WEAVE_ERROR StartTimerT( void )
Start the Trickle rebroadcast algorithm's periodic retransmission timer mechanism.
Details | |
---|---|
Returns |
WEAVE_NO_ERROR if successful, else an INET_ERROR mapped into a WEAVE_ERROR.
|
TeardownTrickleRetransmit
void TeardownTrickleRetransmit( void )
Tear down the Trickle retransmission mechanism by canceling the periodic timers within Trickle and freeing the message buffer holding the Weave message.
UseEphemeralUDPPort
bool UseEphemeralUDPPort( void ) const
Return whether outbound messages sent via the exchange should be sent from the local ephemeral UDP port.
WRMPFlushAcks
WEAVE_ERROR WRMPFlushAcks( void )
WRMPSendDelayedDelivery
WEAVE_ERROR WRMPSendDelayedDelivery( uint32_t PauseTimeMillis, uint64_t DelayedNodeId )
Send a Delayed Delivery message to notify a sender node that its previously sent message would experience an expected delay before being delivered to the recipient.
One of the possible causes for messages to be delayed before being delivered is when the recipient end node is sleepy. This message is potentially generated by a suitable intermediate node in the send path who has enough knowledge of the recipient to infer about the delayed delivery. Upon receiving this message, the sender would re-adjust its retransmission timers for messages that seek acknowledgments back.
Details | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Parameters |
|
||||||||||
Return Values |
|
WRMPSendThrottleFlow
WEAVE_ERROR WRMPSendThrottleFlow( uint32_t PauseTimeMillis )
Send a Throttle Flow message to the peer node requesting it to throttle its sending of messages.
Details | |||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Parameters |
|
||||||||||||
Return Values |
|