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

Implements the communication via WebSockets with the remote server. Outgoing messages are prioritized based on the configured GWSPriorityAssigner instance. Incoming messages are broadcasted via the registered GWSListener instances. The GWSConnectorImpl takes care just for the lowest-level communication details: More...

#include <GWSConnectorImpl.h>

Inheritance diagram for BeeeOn::GWSConnectorImpl:
BeeeOn::AbstractGWSConnector BeeeOn::StoppableRunnable BeeeOn::GWSConnector BeeeOn::Loggable

Public Member Functions

void setHost (const std::string &host)
 
void setPort (int port)
 
void setMaxMessageSize (int size)
 
void setSSLConfig (SSLClient::Ptr config)
 
void setReceiveTimeout (const Poco::Timespan &timeout)
 
void setSendTimeout (const Poco::Timespan &timeout)
 
void setReconnectDelay (const Poco::Timespan &delay)
 
void setKeepAliveTimeout (const Poco::Timespan &timeout)
 
void setMaxFailedReceives (int count)
 
void setGatewayInfo (GatewayInfo::Ptr info)
 
void run ()
 
void stop ()
 
- Public Member Functions inherited from BeeeOn::AbstractGWSConnector
void setOutputsCount (int count)
 
void setPriorityAssigner (GWSPriorityAssigner::Ptr assigner)
 
void setupQueues ()
 Setup queues based on configuration. This must be called before the connector is started.
 
void send (const GWMessage::Ptr message) override
 Put the message into a queue and notify sender to check queues for updates.
 
- Public Member Functions inherited from BeeeOn::GWSConnector
void addListener (GWSListener::Ptr listener)
 Register a GWSListener instance that would receive events related to the communication.
 
void clearListeners ()
 Remove all registered listeners.
 
void setEventsExecutor (AsyncExecutor::Ptr executor)
 Configure an AsyncExecutor instance that would be used for GWSListener events delivery.
 

Protected Member Functions

void waitBeforeReconnect ()
 
Poco::SharedPtr
< Poco::Net::WebSocket > 
connect (const std::string &host, int port) const
 
void performRegister (Poco::Net::WebSocket &socket) const
 
bool performOutput (Poco::Net::WebSocket &socket)
 
void performPing (Poco::Net::WebSocket &socket)
 
void checkPingTimeout () const
 
void outputLoop (StopControl::Run &run, Poco::Net::WebSocket &socket)
 
bool waitOutputs ()
 Wait while the output queues are empty. The waiting delay is driver by the keepAliveTimeout. More...
 
const Poco::Timespan keepAliveRemaining () const
 
void onReadable (const Poco::AutoPtr< Poco::Net::ReadableNotification > &n)
 
void sendMessage (Poco::Net::WebSocket &socket, const GWMessage &message) const
 
void sendFrame (Poco::Net::WebSocket &socket, const std::string &payload, const int flags) const
 
GWMessage::Ptr receiveMessage (Poco::Net::WebSocket &socket) const
 
int receiveFrame (Poco::Net::WebSocket &socket, Poco::Buffer< char > &buffer, int &flags) const
 
- Protected Member Functions inherited from BeeeOn::AbstractGWSConnector
size_t selectOutput () const
 
void updateOutputs (size_t i)
 
bool outputValid (size_t i) const
 
GWMessage::Ptr peekOutput (size_t i) const
 
void popOutput (size_t i)
 Pop the first (oldest) message in the queue of the given index.
 
- Protected Member Functions inherited from BeeeOn::GWSConnector
template<typename Event , typename Method >
void fireEvent (const Event &e, const Method &m)
 
void fireReceived (const GWMessage::Ptr message)
 
- Protected Member Functions inherited from BeeeOn::Loggable
void setupLogger (Poco::Logger *logger=0) const
 
Poco::Logger & logger () const
 
 Loggable (const ClassInfo &info)
 
 Loggable (const std::type_info &info)
 

Additional Inherited Members

- Public Types inherited from BeeeOn::GWSConnector
typedef Poco::SharedPtr
< GWSConnector
Ptr
 
- Public Types inherited from BeeeOn::StoppableRunnable
typedef Poco::SharedPtr
< StoppableRunnable
Ptr
 
- Static Protected Member Functions inherited from BeeeOn::Loggable
static Poco::Logger & forMethod (const char *name)
 
static Poco::Logger & forClass (const ClassInfo &info)
 
static Poco::Logger & forClass (const std::type_info &info)
 
template<typename T >
static Poco::Logger & forInstance (const T *i)
 
static void configureSimple (Poco::Logger &logger, const std::string &level)
 
static void logException (Poco::Logger &logger, const Poco::Message::Priority priority, const Poco::Exception &e, const char *file, size_t line)
 
- Protected Attributes inherited from BeeeOn::AbstractGWSConnector
Poco::Event m_outputsUpdated
 
Poco::Mutex m_outputLock
 

Detailed Description

Implements the communication via WebSockets with the remote server. Outgoing messages are prioritized based on the configured GWSPriorityAssigner instance. Incoming messages are broadcasted via the registered GWSListener instances. The GWSConnectorImpl takes care just for the lowest-level communication details:

Member Function Documentation

const Timespan GWSConnectorImpl::keepAliveRemaining ( ) const
protected
Returns
remaining timeout before keep-alive timeout exceeds
void GWSConnectorImpl::stop ( )
virtual

Stop the runnable. The call should not block.

Implements BeeeOn::StoppableRunnable.

bool GWSConnectorImpl::waitOutputs ( )
protected

Wait while the output queues are empty. The waiting delay is driver by the keepAliveTimeout.

Returns
true if no keep-alive is necessary, false when the keepAliveTimeout has exceeded

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