nl:: Weave:: Profiles:: Echo_Next:: WeaveEchoServer
#include <src/lib/profiles/echo/Next/WeaveEchoServer.h>
Accepts EchoRequest messages from a peer node and responds with an EchoResponse message.
Summary
The WeaveEchoServer class implements the responder side of the Weave Echo protocol. Similar to the ICMP ping protocol, the Weave Echo protocol can be used to test the liveness and reachability of a Weave node.
Applications can use the WeaveEchoServer class to enable automatic response to incoming EchoRequest messages. A corresponding class exists for initiating echo requests (see WeaveEchoClient).
By default the WeaveEchoServer responds immediately to an EchoRequest with response containing the same payload as the request. However this behavior can be altered by the application during processing of the EchoRequestReceived API event.
API Events
During the course of its operation, the WeaveEchoServer object will call up to the application to request specific actions or deliver notifications of important events. These API event calls are made to the currently configured callback function on the server object. Except where noted, applications are free to alter the state of the server during an event callback. One overall exception is the object's Shutdown() method, which may never be called during a callback.
The following API events are defined:
EchoRequestReceived
An EchoRequest message was received from a peer. Arguments to the event contain the request payload, the exchange context over which the message was received and meta-information about the request message.
If the application chooses, it may alter the output arguments to the event to force a delay in responding or to suppress the response altogether. Additionally, it may alter the contents of the payload buffer, which will become the payload for the response message.
EchoResponseSent
An EchoResponse message was sent, or failed to be sent. Arguments to the event contain the error that resulted from sending the message (if any) and the exchange context over which the message was sent.
Inheritance
Inherits from: nl::Weave::WeaveServerBaseDirect Known Subclasses: nl::Weave::DeviceLayer::Internal::EchoServer
Constructors and Destructors |
|
---|---|
WeaveEchoServer(void)
Default constructor for WeaveEchoServer.
|
Public types |
|
---|---|
EchoFunct)(uint64_t nodeId, IPAddress nodeAddr, PacketBuffer *payload)
|
typedefvoid(*
|
EventCallback)(void *appState, EventType eventType, const InEventParam &inParam, OutEventParam &outParam)
|
typedefvoid(*
|
EventType{
|
enum |
Public attributes |
|
---|---|
AppState
|
void *
A pointer to application-specific data.
|
OnEchoRequestReceived
|
EchoFunct
|
Public functions |
|
---|---|
GetEventCallback(void) const
|
EventCallback
Returns a pointer to the API event callback function currently configured on the WeaveEchoServer object.
|
Init(WeaveExchangeManager *exchangeMgr, EventCallback eventCallback, void *appState)
|
Initialize a WeaveEchoServer object.
|
Init(WeaveExchangeManager *exchangeMgr)
|
Initialize a WeaveEchoServer object.
|
SetEventCallback(EventCallback eventCallback)
|
void
Sets the API event callback function on the WeaveEchoServer object.
|
Shutdown(void)
|
Shutdown a previously initialized WeaveEchoServer object.
|
Public static functions |
|
---|---|
DefaultEventHandler(void *appState, EventType eventType, const InEventParam & inParam, OutEventParam & outParam)
|
void
Default handler for WeaveEchoServer API events.
|
Structs |
|
---|---|
nl:: |
Input parameters to WeaveEchoServer API event. |
nl:: |
Output parameters to WeaveEchoServer API event. |
Public types
EchoFunct
void(* EchoFunct)(uint64_t nodeId, IPAddress nodeAddr, PacketBuffer *payload)
EventCallback
void(* EventCallback)(void *appState, EventType eventType, const InEventParam &inParam, OutEventParam &outParam)
EventType
EventType
Public attributes
AppState
void * AppState
A pointer to application-specific data.
OnEchoRequestReceived
EchoFunct OnEchoRequestReceived
Public functions
GetEventCallback
EventCallback GetEventCallback( void ) const
Returns a pointer to the API event callback function currently configured on the WeaveEchoServer object.
Init
WEAVE_ERROR Init( WeaveExchangeManager *exchangeMgr, EventCallback eventCallback, void *appState )
Initialize a WeaveEchoServer object.
Initialize a WeaveEchoServer object to respond to echo messages from a peer.
Details | |||||||
---|---|---|---|---|---|---|---|
Parameters |
|
Init
WEAVE_ERROR Init( WeaveExchangeManager *exchangeMgr )
Initialize a WeaveEchoServer object.
Initialize a WeaveEchoServer object to respond to echo messages from a peer.
DEPRECATED: Please use Init(WeaveExchangeManager * exchangeMgr, EventCallback eventCallback, void * appState).
Details | |||||||
---|---|---|---|---|---|---|---|
Parameters |
|
SetEventCallback
void SetEventCallback( EventCallback eventCallback )
Sets the API event callback function on the WeaveEchoServer object.
Shutdown
WEAVE_ERROR Shutdown( void )
Shutdown a previously initialized WeaveEchoServer object.
Note that this method can only be called if the Init() method has been called previously.
Public static functions
DefaultEventHandler
void DefaultEventHandler( void *appState, EventType eventType, const InEventParam & inParam, OutEventParam & outParam )
Default handler for WeaveEchoServer API events.
Applications are required to call this method for any API events that they don't recognize or handle. Supplied parameters must be the same as those passed by the server object to the application's event handler function.
Details | |||||||||
---|---|---|---|---|---|---|---|---|---|
Parameters |
|