BeeeOn Gateway  v2020.3.1-2-g6f737dc
Platform to interconnect the IoT world
Public Member Functions | Protected Types | Protected Member Functions
BeeeOn::GWSResender Class Reference

Sending of messages via a GWSConnector might not be reliable. Messages that have been sent can never reach the remote server. The GWSResender maintains the sent messages (where a reply is expected). When no response or ack is received on time, such message is sent again. More...

#include <GWSResender.h>

Inheritance diagram for BeeeOn::GWSResender:
BeeeOn::StoppableRunnable BeeeOn::GWSListener BeeeOn::Loggable

Public Member Functions

void setConnector (GWSConnector::Ptr connector)
 
void setResendTimeout (const Poco::Timespan &timeout)
 Configure timeout used to delay each resend.
 
void run () override
 Implement scheduler of the waiting messages.
 
void stop () override
 
void onTrySend (const GWMessage::Ptr message) override
 Fire when a message is about to be sent to the server. After the send is successful (no network failure), the GWSListener::onSend() event would be generated as well.
 
void onSent (const GWMessage::Ptr message) override
 Put the given message into the waiting list if it is re-sendable. After resendTimeout, such message is send again unless an appropriate response/ack has been delivered. More...
 
void onResponse (const GWResponse::Ptr response) override
 When a response is received, this event is fired.
 
void onAck (const GWAck::Ptr ack) override
 When an ack is received, this event is fired.
 
void onOther (const GWMessage::Ptr message) override
 Process GWSensorDataConfirm messages.
 
- Public Member Functions inherited from BeeeOn::GWSListener
virtual void onConnected (const Address &address)
 Fired when the connection to the remote server is successfully created and it is possible to exchange messages.
 
virtual void onDisconnected (const Address &address)
 Fired when the connection to the remote server is considered broken or when it is disconnected on a request.
 
virtual void onRequest (const GWRequest::Ptr request)
 When a request is received, this event is fired.
 

Protected Types

typedef std::multimap
< Poco::Clock, GWMessage::Ptr > 
WaitingList
 

Protected Member Functions

WaitingList::const_iterator resendOrGet (const Poco::Clock &now)
 Resend the oldest message waiting for resend if its timeout has expired. More...
 
WaitingList & waiting ()
 
bool resendable (const GWMessage::Ptr message) const
 Certain messages should be resended when there is no response/ack during the resendTimeout period. This applies to requests, responses with ack and sensor-data-export. More...
 
void findAndDrop (const GWMessage::Ptr message)
 Find the given message in the waiting list and remove it. Such message is considered as delivered or gracefully failed.
 

Additional Inherited Members

- Public Types inherited from BeeeOn::StoppableRunnable
typedef Poco::SharedPtr
< StoppableRunnable
Ptr
 
- Public Types inherited from BeeeOn::GWSListener
typedef Poco::SharedPtr
< GWSListener
Ptr
 

Detailed Description

Sending of messages via a GWSConnector might not be reliable. Messages that have been sent can never reach the remote server. The GWSResender maintains the sent messages (where a reply is expected). When no response or ack is received on time, such message is sent again.

If a message of an existing ID is to be resent, it replaces the previous message of the same ID scheduled for resent. Thus, only the most recent message of the same ID is always scheduled.

Member Function Documentation

void GWSResender::onSent ( const GWMessage::Ptr  message)
overridevirtual

Put the given message into the waiting list if it is re-sendable. After resendTimeout, such message is send again unless an appropriate response/ack has been delivered.

See Also
GWSResender::resendable()

Reimplemented from BeeeOn::GWSListener.

bool GWSResender::resendable ( const GWMessage::Ptr  message) const
protected

Certain messages should be resended when there is no response/ack during the resendTimeout period. This applies to requests, responses with ack and sensor-data-export.

Returns
true if the given message is re-sendable.
GWSResender::WaitingList::const_iterator GWSResender::resendOrGet ( const Poco::Clock &  now)
protected

Resend the oldest message waiting for resend if its timeout has expired.

Returns
the oldest message that is to be resent
void GWSResender::stop ( )
overridevirtual

Stop the runnable. The call should not block.

Implements BeeeOn::StoppableRunnable.

GWSResender::WaitingList & GWSResender::waiting ( )
protected
Returns
the container of waiting messages

The documentation for this class was generated from the following files: