14#include <shared_mutex>
33 return static_cast<ChannelType>(
static_cast<int>(a) |
static_cast<int>(b));
38 return (
static_cast<int>(channelType) &
static_cast<int>(flag)) != 0;
92 virtual void run(std::stop_token st) = 0;
111 std::shared_mutex mtx;
ChannelType
Can be used with | operator to combine them.
Definition Channel.h:20
@ GLOBAL
Bypass the key system and get every message send to the server.
Definition Channel.h:28
@ SLEEPING
Sleeping Channel (can't receive any message)
Definition Channel.h:22
@ METADATA
Receive METADATA on the communication (Conn., Disconn.)
Definition Channel.h:26
@ DATA
Receive the message send by a client.
Definition Channel.h:24
bool hasType(ChannelType channelType, ChannelType flag)
Let you verify if a Channel have a given type easily.
Definition Channel.h:37
ChannelState
Channel's state, tells if the channel can receive data.
Definition Channel.h:17
@ Inactive
Definition Channel.h:17
@ Active
Definition Channel.h:17
ChannelType operator|(ChannelType a, ChannelType b)
Used to combine types.
Definition Channel.h:32
std::queue< ClientData > dataQueue
This queue is used to store (and read) the data send to the Channel by the Server.
Definition Channel.h:103
std::string key
This key must be unique on the server on which it is plugged.
Definition Channel.h:98
ClientData pull()
Pop the first data from the queue and return it.
virtual void run(std::stop_token st)=0
This method is run in a Thread and handle the Channel.
const std::string & getKey()
Return the Channel's key.
void push(ClientData data)
Add the given data at the end of the queue.
ChannelState state
Control if the channel is active or not.
Definition Channel.h:108
void setState(ChannelState state)
Change the state of the server.
bool available()
Return true if data is available inside the dataQueue, false otherwise.
void setKey(const std::string &key)
Defined the Channel's key.
Channel(const std::string &key)
Constructor of the Channel's class.
Structure which hold the Client's Data after an event.
Definition ClientPP.h:43