AlteriomPainlessMesh v2.1.1
Easy ESP32/ESP8266 mesh networking with Alteriom IoT extensions
Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
painlessmesh::tcp::BufferedConnection Class Reference

#include <connection.hpp>

Inheritance diagram for painlessmesh::tcp::BufferedConnection:
Inheritance graph
[legend]
Collaboration diagram for painlessmesh::tcp::BufferedConnection:
Collaboration graph
[legend]

Public Member Functions

 BufferedConnection (AsyncClient *client)
 
 ~BufferedConnection ()
 
void initialize (Scheduler *scheduler)
 
void close ()
 
bool write (const TSTRING &data, bool priority=false)
 
bool writeWithPriority (const TSTRING &data, uint8_t priorityLevel)
 
void onDisconnect (std::function< void()> callback)
 
void onReceive (std::function< void(TSTRING)> callback)
 
bool connected ()
 

Protected Member Functions

bool writeNext ()
 
template<typename T >
std::shared_ptr< T > shared_from (T *derived)
 

Protected Attributes

bool mConnected = true
 
AsyncClient * client
 
Scheduler * mScheduler = nullptr
 
std::function< void(TSTRING)> receiveCallback
 
std::function< void()> disconnectCallback
 
painlessmesh::buffer::ReceiveBuffer< TSTRING > receiveBuffer
 
painlessmesh::buffer::SentBuffer< TSTRING > sentBuffer
 
Task sentBufferTask
 
Task readBufferTask
 

Detailed Description

Class that performs buffered read and write to the tcp connection (asyncclient)

Note that the class expects to be wrapped in a shared_ptr to ensure proper lifetime management. Objects generally will only be destroyed after close is called (and the reading and writing tasks are stopped).

Constructor & Destructor Documentation

◆ BufferedConnection()

painlessmesh::tcp::BufferedConnection::BufferedConnection ( AsyncClient *  client)
inline

Create a buffered connection around the client

BufferedConnection takes ownership of the client and will delete the pointer at the end.

One should always call initialize after construction

◆ ~BufferedConnection()

painlessmesh::tcp::BufferedConnection::~BufferedConnection ( )
inline

Member Function Documentation

◆ close()

void painlessmesh::tcp::BufferedConnection::close ( )
inline

◆ connected()

bool painlessmesh::tcp::BufferedConnection::connected ( )
inline

◆ initialize()

void painlessmesh::tcp::BufferedConnection::initialize ( Scheduler *  scheduler)
inline

◆ onDisconnect()

void painlessmesh::tcp::BufferedConnection::onDisconnect ( std::function< void()>  callback)
inline

◆ onReceive()

void painlessmesh::tcp::BufferedConnection::onReceive ( std::function< void(TSTRING)>  callback)
inline

◆ shared_from()

template<typename T >
std::shared_ptr< T > painlessmesh::tcp::BufferedConnection::shared_from ( T *  derived)
inlineprotected

◆ write()

bool painlessmesh::tcp::BufferedConnection::write ( const TSTRING &  data,
bool  priority = false 
)
inline

◆ writeNext()

bool painlessmesh::tcp::BufferedConnection::writeNext ( )
inlineprotected

◆ writeWithPriority()

bool painlessmesh::tcp::BufferedConnection::writeWithPriority ( const TSTRING &  data,
uint8_t  priorityLevel 
)
inline

Write data with explicit priority level (0-3)

Parameters
dataThe data to send
priorityLevelPriority level: 0=CRITICAL, 1=HIGH, 2=NORMAL, 3=LOW

Member Data Documentation

◆ client

AsyncClient* painlessmesh::tcp::BufferedConnection::client
protected

◆ disconnectCallback

std::function<void()> painlessmesh::tcp::BufferedConnection::disconnectCallback
protected

◆ mConnected

bool painlessmesh::tcp::BufferedConnection::mConnected = true
protected

◆ mScheduler

Scheduler* painlessmesh::tcp::BufferedConnection::mScheduler = nullptr
protected

◆ readBufferTask

Task painlessmesh::tcp::BufferedConnection::readBufferTask
protected

◆ receiveBuffer

painlessmesh::buffer::ReceiveBuffer<TSTRING> painlessmesh::tcp::BufferedConnection::receiveBuffer
protected

◆ receiveCallback

std::function<void(TSTRING)> painlessmesh::tcp::BufferedConnection::receiveCallback
protected

◆ sentBuffer

painlessmesh::buffer::SentBuffer<TSTRING> painlessmesh::tcp::BufferedConnection::sentBuffer
protected

◆ sentBufferTask

Task painlessmesh::tcp::BufferedConnection::sentBufferTask
protected

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