Chatsync  bbffde5c0c672a526bdc83637acf66dc20a80fbf
toxChannel::ToxChannel Class Reference

#include <toxchannel.hpp>

Inheritance diagram for toxChannel::ToxChannel:
channeling::Channel

Public Member Functions

 ToxChannel (Hub::Hub *hub, const std::string &config)
 
 ~ToxChannel ()
 
std::string type () const override
 
- Public Member Functions inherited from channeling::Channel
 Channel (Hub::Hub *const hub, const std::string &config)
 
virtual ~Channel ()
 
virtual std::string const & name () const
 
ChannelDirection direction () const
 
virtual int connect (const std::string &hostname, const uint32_t port) const
 
virtual int send (const uint32_t fd, const std::string &msg) const
 
virtual int send (const std::string &msg) const
 
virtual int disconnect (const uint32_t fd) const
 
virtual int disconnect () const
 
virtual void tick ()
 

Protected Member Functions

void incoming (const messaging::message_ptr &&msg) override
 
- Protected Member Functions inherited from channeling::Channel
void startPolling ()
 
void stopPolling ()
 

Private Member Functions

int toxStart ()
 
std::future< void > activate () override
 
const messaging::message_ptr parse (const char *line) const override
 
void pollThread () override
 

Static Private Member Functions

static void friendRequestCallback (Tox *tox, const uint8_t *public_key, const uint8_t *data, size_t length, void *userdata)
 
static void messageCallback (Tox *tox, uint32_t friendnumber, TOX_MESSAGE_TYPE type, const uint8_t *message, size_t length, void *userdata)
 
template<typename MsgType >
static void groupMessageCallback (Tox *tox, int32_t groupnumber, int32_t peernumber, const uint8_t *message, uint16_t length, void *userdata)
 

Private Attributes

Tox *const _tox
 
bool wasConnected
 

Static Private Attributes

static const channeling::ChannelCreatorImpl< ToxChannelcreator
 

Additional Inherited Members

- Data Fields inherited from channeling::Channel
const uint16_t _id
 
- Protected Attributes inherited from channeling::Channel
std::atomic_bool _active
 
std::unique_ptr< std::thread > _thread
 
std::atomic_bool _pipeRunning
 
int _fd
 
const config::ConfigParser _config
 
const std::string _name
 
const ChannelDirection _direction
 
Hub::Hub *const _hub
 

Detailed Description

Tox channel

Constructor & Destructor Documentation

§ ToxChannel()

toxChannel::ToxChannel::ToxChannel ( Hub::Hub hub,
const std::string &  config 
)
explicit

§ ~ToxChannel()

toxChannel::ToxChannel::~ToxChannel ( )

Member Function Documentation

§ activate()

std::future< void > toxChannel::ToxChannel::activate ( )
overrideprivatevirtual

Prepare all prerequisites for polling thread or prepare the output and start working

Opening file descriptors, connecting to network must be done here. After future is valid channel is considered to be ready for work.

Exceptions
activate_errorin case of problems

Implements channeling::Channel.

§ friendRequestCallback()

void toxChannel::ToxChannel::friendRequestCallback ( Tox *  tox,
const uint8_t *  public_key,
const uint8_t *  data,
size_t  length,
void *  userdata 
)
staticprivate
Todo:
check friend_error

§ groupMessageCallback()

template<typename MsgType >
void toxChannel::ToxChannel::groupMessageCallback ( Tox *  tox,
int32_t  groupnumber,
int32_t  peernumber,
const uint8_t *  message,
uint16_t  length,
void *  userdata 
)
staticprivate

§ incoming()

void toxChannel::ToxChannel::incoming ( const messaging::message_ptr &&  msg)
overrideprotectedvirtual

Parse line and send it to needed output place in case of Output direction

Parameters
msgIncoming message from hub. Passed by value to preserve ownership and ensure existence during processing in all output channels.

Implements channeling::Channel.

§ messageCallback()

void toxChannel::ToxChannel::messageCallback ( Tox *  tox,
uint32_t  friendnumber,
TOX_MESSAGE_TYPE  type,
const uint8_t *  message,
size_t  length,
void *  userdata 
)
staticprivate

§ parse()

const messaging::message_ptr toxChannel::ToxChannel::parse ( const char *  line) const
overrideprivatevirtual

This would be useful if Tox read something from socket

Implements channeling::Channel.

§ pollThread()

void toxChannel::ToxChannel::pollThread ( )
overrideprivatevirtual

Thread for tox infinite loop

Reimplemented from channeling::Channel.

§ toxStart()

int toxChannel::ToxChannel::toxStart ( )
private

§ type()

std::string toxChannel::ToxChannel::type ( ) const
inlineoverridevirtual

Return channel "type" — unique string to identify channel in config file

Return values
std::stringType line

Implements channeling::Channel.

Field Documentation

§ _tox

Tox* const toxChannel::ToxChannel::_tox
private

Main tox structure

§ creator

const channeling::ChannelCreatorImpl< ToxChannel > toxChannel::ToxChannel::creator
staticprivate

§ wasConnected

bool toxChannel::ToxChannel::wasConnected
private

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