nl::Weave::WeaveExchangeManager

#include <src/lib/core/WeaveExchangeMgr.h>

This class is used to manage ExchangeContexts with other Weave nodes.

Summary

It works on behalf of higher layers, creating ExchangeContexts and handling the registration/unregistration of unsolicited message handlers.

Constructors and Destructors

WeaveExchangeManager(void)
Constructor for the WeaveExchangeManager class.

Public types

State{
  kState_NotInitialized = 0,
  kState_Initialized = 1
}
enum

Public attributes

FabricState
[READ ONLY] The associated FabricState object.
MessageLayer
[READ ONLY] The associated WeaveMessageLayer object.
State
uint8_t
[READ ONLY] The state of the WeaveExchangeManager object.

Public functions

AllowUnsolicitedMessages(WeaveConnection *con)
void
Allow unsolicited messages to be received on the specified connection.
ClearMsgCounterSyncReq(uint64_t peerNodeId)
void
Clear MsgCounterSyncReq flag for all pending messages to that peer.
FindContext(uint64_t peerNodeId, WeaveConnection *con, void *appState, bool isInitiator)
Find the ExchangeContext from a pool matching a given set of parameters.
Init(WeaveMessageLayer *msgLayer)
Initialize the WeaveExchangeManager object.
NewBinding(Binding::EventCallback eventCallback, void *appState)
Allocate a new Binding with the arguments supplied.
NewContext(const uint64_t & peerNodeId, void *appState)
Creates a new ExchangeContext with a given peer Weave node specified by the peer node identifier.
NewContext(const uint64_t & peerNodeId, const IPAddress & peerAddr, void *appState)
Creates a new ExchangeContext with a given peer Weave node specified by the peer node identifier and peer IP address.
NewContext(const uint64_t & peerNodeId, const IPAddress & peerAddr, uint16_t peerPort, InterfaceId sendIntfId, void *appState)
Creates a new ExchangeContext with a given peer Weave node specified by the peer node identifier, peer IP address, and destination port on a specified interface.
NewContext(WeaveConnection *con, void *appState)
Creates a new ExchangeContext with a given peer Weave node over a specified WeaveConnection.
RegisterUnsolicitedMessageHandler(uint32_t profileId, ExchangeContext::MessageReceiveFunct handler, void *appState)
Register an unsolicited message handler for a given profile identifier.
RegisterUnsolicitedMessageHandler(uint32_t profileId, ExchangeContext::MessageReceiveFunct handler, bool allowDups, void *appState)
Register an unsolicited message handler for a given profile identifier.
RegisterUnsolicitedMessageHandler(uint32_t profileId, uint8_t msgType, ExchangeContext::MessageReceiveFunct handler, void *appState)
Register an unsolicited message handler for a given profile identifier and message type.
RegisterUnsolicitedMessageHandler(uint32_t profileId, uint8_t msgType, ExchangeContext::MessageReceiveFunct handler, bool allowDups, void *appState)
Register an unsolicited message handler for a given profile identifier and message type.
RegisterUnsolicitedMessageHandler(uint32_t profileId, uint8_t msgType, WeaveConnection *con, ExchangeContext::MessageReceiveFunct handler, void *appState)
Register an unsolicited message handler for a given profile identifier, message type on a specified Weave connection.
RegisterUnsolicitedMessageHandler(uint32_t profileId, uint8_t msgType, WeaveConnection *con, ExchangeContext::MessageReceiveFunct handler, bool allowDups, void *appState)
Register an unsolicited message handler for a given profile identifier, message type on a specified Weave connection.
Shutdown(void)
Shutdown the WeaveExchangeManager.
UnregisterUnsolicitedMessageHandler(uint32_t profileId)
Unregister an unsolicited message handler for a given profile identifier.
UnregisterUnsolicitedMessageHandler(uint32_t profileId, uint8_t msgType)
Unregister an unsolicited message handler for a given profile identifier and message type.
UnregisterUnsolicitedMessageHandler(uint32_t profileId, uint8_t msgType, WeaveConnection *con)
Unregister an unsolicited message handler for a given profile identifier, message type, and Weave connection.

Public types

State

 State
Properties
kState_Initialized

Used to indicate that the WeaveExchangeManager is initialized.

kState_NotInitialized

Used to indicate that the WeaveExchangeManager is not initialized.

Public attributes

FabricState

WeaveFabricState * FabricState

[READ ONLY] The associated FabricState object.

MessageLayer

WeaveMessageLayer * MessageLayer

[READ ONLY] The associated WeaveMessageLayer object.

State

uint8_t State

[READ ONLY] The state of the WeaveExchangeManager object.

Public functions

AllowUnsolicitedMessages

void AllowUnsolicitedMessages(
  WeaveConnection *con
)

Allow unsolicited messages to be received on the specified connection.

This method sets the message reception handler on the given Weave connection.

Details
Parameters
[in] con
A pointer to the Weave connection object.

ClearMsgCounterSyncReq

void ClearMsgCounterSyncReq(
  uint64_t peerNodeId
)

Clear MsgCounterSyncReq flag for all pending messages to that peer.

Details
Parameters
[in] peerNodeId
Node ID of the destination node.

FindContext

ExchangeContext * FindContext(
  uint64_t peerNodeId,
  WeaveConnection *con,
  void *appState,
  bool isInitiator
)

Find the ExchangeContext from a pool matching a given set of parameters.

Details
Parameters
[in] peerNodeId
The node identifier of the peer with which the ExchangeContext has been set up.
[in] con
A pointer to the WeaveConnection object representing the TCP connection with the peer.
[in] appState
A pointer to a higher layer object that holds context state.
[in] isInitiator
Boolean indicator of whether the local node is the initiator of the exchange.
Returns
A pointer to the ExchangeContext object matching the provided parameters On success, NULL on no match.

Init

WEAVE_ERROR Init(
  WeaveMessageLayer *msgLayer
)

Initialize the WeaveExchangeManager object.

Within the lifetime of this instance, this method is invoked once after object construction until a call to Shutdown is made to terminate the instance.

Details
Parameters
[in] msgLayer
A pointer to the WeaveMessageLayer object.
Return Values
WEAVE_ERROR_INCORRECT_STATE
If the state is not equal to kState_NotInitialized.
WEAVE_NO_ERROR
On success.

NewBinding

Binding * NewBinding(
  Binding::EventCallback eventCallback,
  void *appState
)

Allocate a new Binding with the arguments supplied.

Details
Parameters
[in] eventCallback
A function pointer to be used for event callback
[in] appState
A pointer to some context which would be carried in event callback later
Returns
A pointer to the newly allocated Binding, or NULL if the pool has been exhausted

NewContext

ExchangeContext * NewContext(
  const uint64_t & peerNodeId,
  void *appState
)

Creates a new ExchangeContext with a given peer Weave node specified by the peer node identifier.

Details
Parameters
[in] peerNodeId
The node identifier of the peer with which the ExchangeContext is being set up.
[in] appState
A pointer to a higher layer object that holds context state.
Returns
A pointer to the created ExchangeContext object On success. Otherwise NULL if no object can be allocated or is available.

NewContext

ExchangeContext * NewContext(
  const uint64_t & peerNodeId,
  const IPAddress & peerAddr,
  void *appState
)

Creates a new ExchangeContext with a given peer Weave node specified by the peer node identifier and peer IP address.

Details
Parameters
[in] peerNodeId
The node identifier of the peer with which the ExchangeContext is being set up.
[in] peerAddr
The IP address of the peer node.
[in] appState
A pointer to a higher layer object that holds context state.
Returns
A pointer to the created ExchangeContext object On success. Otherwise, NULL if no object can be allocated or is available.

NewContext

ExchangeContext * NewContext(
  const uint64_t & peerNodeId,
  const IPAddress & peerAddr,
  uint16_t peerPort,
  InterfaceId sendIntfId,
  void *appState
)

Creates a new ExchangeContext with a given peer Weave node specified by the peer node identifier, peer IP address, and destination port on a specified interface.

Details
Parameters
[in] peerNodeId
The node identifier of the peer with which the ExchangeContext is being set up.
[in] peerAddr
The IP address of the peer node.
[in] peerPort
The port of the peer node.
[in] sendIntfId
The interface to use for sending Weave messages on this exchange.
[in] appState
A pointer to a higher layer object that holds context state.
Returns
A pointer to the created ExchangeContext object On success. Otherwise, NULL if no object can be allocated or is available.

NewContext

ExchangeContext * NewContext(
  WeaveConnection *con,
  void *appState
)

Creates a new ExchangeContext with a given peer Weave node over a specified WeaveConnection.

Details
Parameters
[in] con
A pointer to the WeaveConnection object representing the TCP connection with the peer.
[in] appState
A pointer to a higher layer object that holds context state.
Returns
A pointer to the created ExchangeContext object On success. Otherwise, NULL if no object can be allocated or is available.

RegisterUnsolicitedMessageHandler

WEAVE_ERROR RegisterUnsolicitedMessageHandler(
  uint32_t profileId,
  ExchangeContext::MessageReceiveFunct handler,
  void *appState
)

Register an unsolicited message handler for a given profile identifier.

This handler would be invoked for all messages of the given profile.

Details
Parameters
[in] profileId
The profile identifier of the received message.
[in] handler
The unsolicited message handler.
[in] appState
A pointer to a higher layer object that holds context state.
Return Values
WEAVE_ERROR_TOO_MANY_UNSOLICITED_MESSAGE_HANDLERS
If the unsolicited message handler pool is full and a new one cannot be allocated.
WEAVE_NO_ERROR
On success.

RegisterUnsolicitedMessageHandler

WEAVE_ERROR RegisterUnsolicitedMessageHandler(
  uint32_t profileId,
  ExchangeContext::MessageReceiveFunct handler,
  bool allowDups,
  void *appState
)

Register an unsolicited message handler for a given profile identifier.

This handler would be invoked for all messages of the given profile.

Details
Parameters
[in] profileId
The profile identifier of the received message.
[in] handler
The unsolicited message handler.
[in] allowDups
Boolean indicator of whether duplicate messages are allowed for a given profile.
[in] appState
A pointer to a higher layer object that holds context state.
Return Values
WEAVE_ERROR_TOO_MANY_UNSOLICITED_MESSAGE_HANDLERS
If the unsolicited message handler pool is full and a new one cannot be allocated.
WEAVE_NO_ERROR
On success.

RegisterUnsolicitedMessageHandler

WEAVE_ERROR RegisterUnsolicitedMessageHandler(
  uint32_t profileId,
  uint8_t msgType,
  ExchangeContext::MessageReceiveFunct handler,
  void *appState
)

Register an unsolicited message handler for a given profile identifier and message type.

Details
Parameters
[in] profileId
The profile identifier of the received message.
[in] msgType
The message type of the corresponding profile.
[in] handler
The unsolicited message handler.
[in] appState
A pointer to a higher layer object that holds context state.
Return Values
WEAVE_ERROR_TOO_MANY_UNSOLICITED_MESSAGE_HANDLERS
If the unsolicited message handler pool is full and a new one cannot be allocated.
WEAVE_NO_ERROR
On success.

RegisterUnsolicitedMessageHandler

WEAVE_ERROR RegisterUnsolicitedMessageHandler(
  uint32_t profileId,
  uint8_t msgType,
  ExchangeContext::MessageReceiveFunct handler,
  bool allowDups,
  void *appState
)

Register an unsolicited message handler for a given profile identifier and message type.

Details
Parameters
[in] profileId
The profile identifier of the received message.
[in] msgType
The message type of the corresponding profile.
[in] handler
The unsolicited message handler.
[in] allowDups
Boolean indicator of whether duplicate messages are allowed for a given profile identifier and message type.
[in] appState
A pointer to a higher layer object that holds context state.
Return Values
WEAVE_ERROR_TOO_MANY_UNSOLICITED_MESSAGE_HANDLERS
If the unsolicited message handler pool is full and a new one cannot be allocated.
WEAVE_NO_ERROR
On success.

RegisterUnsolicitedMessageHandler

WEAVE_ERROR RegisterUnsolicitedMessageHandler(
  uint32_t profileId,
  uint8_t msgType,
  WeaveConnection *con,
  ExchangeContext::MessageReceiveFunct handler,
  void *appState
)

Register an unsolicited message handler for a given profile identifier, message type on a specified Weave connection.

Details
Parameters
[in] profileId
The profile identifier of the received message.
[in] msgType
The message type of the corresponding profile.
[in] con
A pointer to the WeaveConnection object representing the TCP connection with the peer.
[in] handler
The unsolicited message handler.
[in] appState
A pointer to a higher layer object that holds context state.
Return Values
WEAVE_ERROR_TOO_MANY_UNSOLICITED_MESSAGE_HANDLERS
If the unsolicited message handler pool is full and a new one cannot be allocated.
WEAVE_NO_ERROR
On success.

RegisterUnsolicitedMessageHandler

WEAVE_ERROR RegisterUnsolicitedMessageHandler(
  uint32_t profileId,
  uint8_t msgType,
  WeaveConnection *con,
  ExchangeContext::MessageReceiveFunct handler,
  bool allowDups,
  void *appState
)

Register an unsolicited message handler for a given profile identifier, message type on a specified Weave connection.

Details
Parameters
[in] profileId
The profile identifier of the received message.
[in] msgType
The message type of the corresponding profile.
[in] con
A pointer to the WeaveConnection object representing the TCP connection with the peer.
[in] handler
The unsolicited message handler.
[in] allowDups
Boolean indicator of whether duplicate messages are allowed for a given profile identifier, message type on a specified Weave connection.
[in] appState
A pointer to a higher layer object that holds context state.
Return Values
WEAVE_ERROR_TOO_MANY_UNSOLICITED_MESSAGE_HANDLERS
If the unsolicited message handler pool is full and a new one cannot be allocated.
WEAVE_NO_ERROR
On success.

Shutdown

WEAVE_ERROR Shutdown(
  void
)

Shutdown the WeaveExchangeManager.

This terminates this instance of the object and releases all held resources.

Details
Returns
WEAVE_NO_ERROR unconditionally.

UnregisterUnsolicitedMessageHandler

WEAVE_ERROR UnregisterUnsolicitedMessageHandler(
  uint32_t profileId
)

Unregister an unsolicited message handler for a given profile identifier.

Details
Parameters
[in] profileId
The profile identifier of the received message.
Return Values
WEAVE_ERROR_NO_UNSOLICITED_MESSAGE_HANDLER
If the matching unsolicited message handler is not found.
WEAVE_NO_ERROR
On success.

UnregisterUnsolicitedMessageHandler

WEAVE_ERROR UnregisterUnsolicitedMessageHandler(
  uint32_t profileId,
  uint8_t msgType
)

Unregister an unsolicited message handler for a given profile identifier and message type.

Details
Parameters
[in] profileId
The profile identifier of the received message.
[in] msgType
The message type of the corresponding profile.
Return Values
WEAVE_ERROR_NO_UNSOLICITED_MESSAGE_HANDLER
If the matching unsolicited message handler is not found.
WEAVE_NO_ERROR
On success.

UnregisterUnsolicitedMessageHandler

WEAVE_ERROR UnregisterUnsolicitedMessageHandler(
  uint32_t profileId,
  uint8_t msgType,
  WeaveConnection *con
)

Unregister an unsolicited message handler for a given profile identifier, message type, and Weave connection.

Details
Parameters
[in] profileId
The profile identifier of the received message.
[in] msgType
The message type of the corresponding profile.
[in] con
A pointer to the WeaveConnection object representing the TCP connection with the peer.
Return Values
WEAVE_ERROR_NO_UNSOLICITED_MESSAGE_HANDLER
If the matching unsolicited message handler is not found.
WEAVE_NO_ERROR
On success.

WeaveExchangeManager

 WeaveExchangeManager(
  void
)

Constructor for the WeaveExchangeManager class.

It sets the state to kState_NotInitialized.