#include <ClientPP.h>
|
| ClientPP (Client clientInfo) |
| Constructor of the REMOTE client.
|
|
| ClientPP (const std::string &address, int port, const std::string &separator, IP_Type ipType=IP_Type::IPv4, bool useCiphering=true) |
| Constructor of the LOCAL client.
|
|
| ~ClientPP () |
| Destructor of the ClientPP class.
|
|
void | send (const std::string &data, ConnType connType=ConnType::TCP) |
| This method can be used by both LOCAL and REMOTE client to exchange with the Server/Clients.
|
|
const std::string & | getID () |
| Return the Client's identity string.
|
|
void | kick () |
| Kick the client by closing its socket.
|
|
const Client & | getClientStruct () |
| Return a reference to the client structure.
|
|
void | start () |
| Connect the client and start the run loop.
|
|
void | addDataCallback (const std::string &key, std::function< void(std::vector< std::string >)> callback) |
| Add a callback for the DataReceived event.
|
|
void | addDisconnectionCallback (std::function< void(void)> callback) |
| Add a callback for the Disconnection event.
|
|
bool | getHaveSecret () |
| Return the haveSecret boolean value.
|
|
void | stop () |
| Stop the client by terminating its run loop and disconnect it from the server.
|
|
void | setSharedSecret (const std::string &PK) |
| Let you set the public key to compute the shared secret.
|
|
std::string | decrypt (const std::string &cipher) |
| Return the decrypted string of the given cipher.
|
|
void | setKeysPaths (const std::string &PKFile, const std::string &SKFile) |
| Set the public and private keys for the [LOCAL] client.
|
|
void | setServerPKPath (const std::string &SPKFile) |
| Set the server's public key for the [LOCAL] client.
|
|
|
void | run (std::stop_token st) |
| Main loop of the client, it listens to the events and process them.
|
|
void | init () |
| Init the different informations of the client.
|
|
|
std::shared_ptr< SymmetricCipherInterface > | symmetricCipher |
| Have the information of the symmetricKey used for the communication between the Server and the Client.
|
|
std::unique_ptr< KeyExchangeInterface > | kxInterface |
| Key used for the ECDH symmetricKey exchange.
|
|
Client * | clientTCP |
| TCP client pointer.
|
|
Client * | clientUDP |
| UDP client pointer.
|
|
ClientType | type |
| Information of the client's type REMOTE or LOCAL.
|
|
std::string | ID |
| String "address:port".
|
|
bool | isDisconnected |
| Boolean which is used to stop using the client when kicked.
|
|
std::stop_source | stopTag |
| This parameter is used to stop the run loop.
|
|
bool | haveSecret |
| Tells if the secret has been computed.
|
|
bool | useCiphering |
| Tells if the client use ciphering.
|
|
std::jthread | runThread |
| Run thread.
|
|
std::string | address |
| Server's address.
|
|
int | port |
| Server's port.
|
|
IP_Type | ipType |
| Session's IP type (IPv4 or IPv6)
|
|
std::unordered_map< std::string, std::function< void(std::vector< std::string >)> > | dataRcvCB |
| This map register the callback for the DataReceived's events.
|
|
std::vector< std::function< void(void)> > | disconnCB |
| This map register the callback for the Disconnection's events.
|
|
std::string | PKFile |
| Paths to the public and private keys.
|
|
std::string | SKFile |
|
std::string | ServerPKFile |
| Path to the server Public Key file.
|
|
◆ ClientPP() [1/2]
ClientPP::ClientPP |
( |
Client | clientInfo | ) |
|
Constructor of the REMOTE client.
- Parameters
-
clientInfo | Client structure with the necessary information. |
◆ ClientPP() [2/2]
ClientPP::ClientPP |
( |
const std::string & | address, |
|
|
int | port, |
|
|
const std::string & | separator, |
|
|
IP_Type | ipType = IP_Type::IPv4, |
|
|
bool | useCiphering = true ) |
Constructor of the LOCAL client.
- Parameters
-
address | Server's address. |
port | Server's port. |
separator | Separator used during this session. |
ipType | IP type (IPv4 or IPv6) of this connection. |
useCiphering | Indication about the usage of ciphering in this session. |
◆ ~ClientPP()
◆ addDataCallback()
void ClientPP::addDataCallback |
( |
const std::string & | key, |
|
|
std::function< void(std::vector< std::string >)> | callback ) |
Add a callback for the DataReceived event.
Each time a message with the given key as prefix is received, the callback will be called with the received data as parameter.
Key is unique, but you can create a callback which will propagate the information.
- Parameters
-
key | Prefix which will trigger the callback method. Should be unique. |
callback | Callback of the following form void(vector<string>). |
◆ addDisconnectionCallback()
void ClientPP::addDisconnectionCallback |
( |
std::function< void(void)> | callback | ) |
|
Add a callback for the Disconnection event.
Called when a disconnection happen.
- Parameters
-
callback | Callback of the following form void(void). |
◆ decrypt()
std::string ClientPP::decrypt |
( |
const std::string & | cipher | ) |
|
Return the decrypted string of the given cipher.
- Parameters
-
◆ getClientStruct()
const Client & ClientPP::getClientStruct |
( |
| ) |
|
Return a reference to the client structure.
◆ getHaveSecret()
bool ClientPP::getHaveSecret |
( |
| ) |
|
Return the haveSecret boolean value.
haveSecret is true when the shared secret has been compute.
It does not tell you that the secret is the same between the server and the client.
◆ getID()
const std::string & ClientPP::getID |
( |
| ) |
|
Return the Client's identity string.
Which is "address:port".
- Warning
- Is an ID only locally, client-side or server-side, not accross the network.
◆ init()
Init the different informations of the client.
Its ID and KISS classes when needed.
◆ kick()
Kick the client by closing its socket.
◆ run()
void ClientPP::run |
( |
std::stop_token | st | ) |
|
|
protected |
Main loop of the client, it listens to the events and process them.
- Parameters
-
st | Stop token used to stop the loop of the thread. |
◆ send()
void ClientPP::send |
( |
const std::string & | data, |
|
|
ConnType | connType = ConnType::TCP ) |
This method can be used by both LOCAL and REMOTE client to exchange with the Server/Clients.
- Warning
- For REMOTE clients, don't use this method for UDP communications.
- See also
- sendUDP to answer with UDP.
- Parameters
-
data | Data to send to the peer (client or server) |
connType | Type of connection to be used for the message, could be ConnType::TCP or ConnType::UDP (default : ConnType::TCP) |
◆ setKeysPaths()
void ClientPP::setKeysPaths |
( |
const std::string & | PKFile, |
|
|
const std::string & | SKFile ) |
Set the public and private keys for the [LOCAL] client.
- Warning
- Only available for the LOCAL client.
- Parameters
-
PKFile | Path to the public key's file. |
SKFile | Path to the secret key's file. |
◆ setServerPKPath()
void ClientPP::setServerPKPath |
( |
const std::string & | SPKFile | ) |
|
Set the server's public key for the [LOCAL] client.
- Warning
- Only available for the LOCAL client.
- Parameters
-
SPKFile | Path to the server's public key file |
◆ setSharedSecret()
void ClientPP::setSharedSecret |
( |
const std::string & | PK | ) |
|
Let you set the public key to compute the shared secret.
The given string will be considered as the peer's public key and use to compute the shared secret.
◆ start()
Connect the client and start the run loop.
Method for the LOCAL client which handles the connection and start the run method in a jthread.
◆ stop()
Stop the client by terminating its run loop and disconnect it from the server.
- Warning
- Only available on LOCAL clients.
Also, properly clear clientTCP and clientUDP.
◆ address
std::string ClientPP::address |
|
protected |
◆ clientTCP
Client* ClientPP::clientTCP |
|
protected |
◆ clientUDP
Client* ClientPP::clientUDP |
|
protected |
◆ dataRcvCB
std::unordered_map<std::string, std::function<void(std::vector<std::string>)> > ClientPP::dataRcvCB |
|
protected |
This map register the callback for the DataReceived's events.
"" is the default callback, called when no key is detected, if it does not exist the message is just ignored.
◆ disconnCB
std::vector<std::function<void(void)> > ClientPP::disconnCB |
|
protected |
This map register the callback for the Disconnection's events.
◆ haveSecret
bool ClientPP::haveSecret |
|
protected |
Tells if the secret has been computed.
◆ ID
◆ ipType
Session's IP type (IPv4 or IPv6)
◆ isDisconnected
bool ClientPP::isDisconnected |
|
protected |
Boolean which is used to stop using the client when kicked.
◆ kxInterface
std::unique_ptr<KeyExchangeInterface> ClientPP::kxInterface |
|
protected |
Key used for the ECDH symmetricKey exchange.
Both the public key and the private key are stored inside the KXInterface from KISS.
◆ PKFile
std::string ClientPP::PKFile |
|
protected |
Paths to the public and private keys.
◆ port
◆ runThread
std::jthread ClientPP::runThread |
|
protected |
◆ ServerPKFile
std::string ClientPP::ServerPKFile |
|
protected |
Path to the server Public Key file.
◆ SKFile
std::string ClientPP::SKFile |
|
protected |
◆ stopTag
std::stop_source ClientPP::stopTag |
|
protected |
This parameter is used to stop the run loop.
◆ symmetricCipher
std::shared_ptr<SymmetricCipherInterface> ClientPP::symmetricCipher |
|
protected |
Have the information of the symmetricKey used for the communication between the Server and the Client.
Server-side : keep the information for the server.
◆ type
Information of the client's type REMOTE or LOCAL.
◆ useCiphering
bool ClientPP::useCiphering |
|
protected |
Tells if the client use ciphering.
The documentation for this class was generated from the following file: