NSCpp 2.0
NSCpp is a modern C++20 server/client framework designed to simplify network programming in C++. With robust support for both IPv4 and IPv6, as well as TCP and UDP communication protocols.
 
Loading...
Searching...
No Matches
HelperChannel Class Reference

Project NSCpp. More...

#include <HelperChannel.h>

Inheritance diagram for HelperChannel:
Channel

Public Member Functions

 HelperChannel (const std::string &key, const std::string &logKey="logChannel", bool doLogging=true)
 Constructor of the HelperChannel.
 
void run (std::stop_token st)
 Run method of the Channel, process the given events.
 
void addChannelKey (const std::string &key)
 Used as a callback which listen to the "ServerChannelPlug" group.
 
void removeChannelKey (const std::string &key)
 Used as a callback which listen to the "ServerChannelUnplug" group.
 
- Public Member Functions inherited from Channel
 Channel (const std::string &key)
 Constructor of the Channel's class.
 
void setKey (const std::string &key)
 Defined the Channel's key.
 
const std::string & getKey ()
 Return the Channel's key.
 
void setState (ChannelState state)
 Change the state of the server.
 
void push (ClientData data)
 Add the given data at the end of the queue.
 
ClientData pull ()
 Pop the first data from the queue and return it.
 
bool available ()
 Return true if data is available inside the dataQueue, false otherwise.
 

Protected Attributes

std::unordered_set< std::string > keys
 Keep the keys of the plugged channels.
 
bool logging
 Tells if the channel is supposed to log.
 
std::string logKey
 Key of the log channel's group.
 
- Protected Attributes inherited from Channel
std::string key
 This key must be unique on the server on which it is plugged.
 
std::queue< ClientDatadataQueue
 This queue is used to store (and read) the data send to the Channel by the Server.
 
ChannelState state
 Control if the channel is active or not.
 

Detailed Description

Project NSCpp.

Author
Thomas K/BIDI
Version
2.0

Constructor & Destructor Documentation

◆ HelperChannel()

HelperChannel::HelperChannel ( const std::string & key,
const std::string & logKey = "logChannel",
bool doLogging = true )

Constructor of the HelperChannel.

Parameters
keyChannel's key.
logKeyKey of the log channel group which can be used to log the debug information (default : "logChannel").
doLoggingTells if the Channel should log its actions.

Member Function Documentation

◆ addChannelKey()

void HelperChannel::addChannelKey ( const std::string & key)

Used as a callback which listen to the "ServerChannelPlug" group.

When a new Channel is plug, the server emit in a group which call this method to add the newly plugged Channel.

Parameters
keyNewly plugged Channel's key.

◆ removeChannelKey()

void HelperChannel::removeChannelKey ( const std::string & key)

Used as a callback which listen to the "ServerChannelUnplug" group.

When a Channel is unplug, the server emit in a group which call this method to remove the unplugged Channel.

Parameters
keyUnplugged Channel's key.

◆ run()

void HelperChannel::run ( std::stop_token st)
virtual

Run method of the Channel, process the given events.

Implements Channel.

Member Data Documentation

◆ keys

std::unordered_set<std::string> HelperChannel::keys
protected

Keep the keys of the plugged channels.

◆ logging

bool HelperChannel::logging
protected

Tells if the channel is supposed to log.

◆ logKey

std::string HelperChannel::logKey
protected

Key of the log channel's group.


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