11#include <unordered_map>
12#include <unordered_set>
41 ServerPP(std::string address,
int port, std::string separator, IP_Type ipType = IP_Type::IPv4,
bool useCiphering =
true,
const std::string& publicKeyFile =
"",
const std::string& privateKeyFile =
"");
102 void kicked(
const std::string& clientID);
109 std::unique_ptr<KeyExchangeInterface> kxInterface;
117 std::unordered_map<std::string, std::pair<ChannelType, std::shared_ptr<Channel>>> channels;
123 std::unordered_map<std::string, std::stop_source> stopSources;
131 std::unordered_map<std::string, std::shared_ptr<ClientPP>> clients;
136 std::stop_source stopTag;
139 Server *serverTCP, *serverUDP;
153 std::string separator;
161 std::jthread runThread;
164 std::vector<std::jthread> channelsThreads;
172 void process(ServerEvent& event,
const ConnType& connType);
178 void run(std::stop_token st);
ChannelType
Can be used with | operator to combine them.
Definition Channel.h:20
ChannelState
Channel's state, tells if the channel can receive data.
Definition Channel.h:17
~ServerPP()
Destructor of the ServerPP class.
void setChannelState(const std::string &key, const ChannelState &state)
Update a channel state through the server.
void start()
Create the servers (TCP and UDP) with the given parameters and start the run method.
void stop()
Stop the server, disconnect properly every clients and clear everything.
void unplug(const std::string &key)
Unplug a channel based on its key.
std::vector< std::string > getChannelKeys()
Return a list which contains every plugged channel's keys.
void plug(std::shared_ptr< Channel > channel, ChannelType type)
Plug a new channel to the server and start it in a jthread.
void kicked(const std::string &clientID)
Callback used to tell the server you kicked a client.
ServerPP(std::string address, int port, std::string separator, IP_Type ipType=IP_Type::IPv4, bool useCiphering=true, const std::string &publicKeyFile="", const std::string &privateKeyFile="")
Constructor of the ServerPP.