pairpal
Loading...
Searching...
No Matches
client.hpp
1#ifndef CLIENT_HPP
2#define CLIENT_HPP
3
4#include <string>
5#include <vector>
6#include <zmq.hpp>
7
12class Client {
13 public:
18 explicit Client(std::string serverAddr);
19
24 Client(const Client& other);
25
30 Client(Client&& other) noexcept;
31
37 auto operator=(const Client& other) -> Client&;
38
44 auto operator=(Client&& other) noexcept -> Client&;
45
50
55 auto start() noexcept -> bool;
56
61 auto stop() noexcept -> bool;
62
67 auto restart() noexcept -> bool;
68
75 auto addUser(const std::string& username,
76 const std::string& password) noexcept -> bool;
77
83 auto removeUser(const std::string& username) noexcept -> bool;
84
90 auto isExistUser(const std::string& username) noexcept -> bool;
91
96 [[nodiscard]] auto listAllUsers() -> std::vector<std::string>;
97
104 auto authenticateUser(const std::string& username,
105 const std::string& password) noexcept -> bool;
106
113 auto addUserTag(const std::string& username, const std::string& tag) noexcept
114 -> bool;
115
122 auto removeUserTag(const std::string& username,
123 const std::string& tag) noexcept -> bool;
124
130 [[nodiscard]] auto getUserTags(const std::string& username)
131 -> std::vector<std::string>;
132
140 auto sendMessage(const std::string& from, const std::string& to,
141 const std::string& message) noexcept -> bool;
142
148 [[nodiscard]] auto getSentMessages(const std::string& username)
149 -> std::vector<std::string>;
150
156 [[nodiscard]] auto getReceivedMessages(const std::string& username)
157 -> std::vector<std::string>;
158
164 [[nodiscard]] auto getPair(const std::string& username)
165 -> std::vector<std::string>;
166
167 private:
168 std::string serverAddr_;
169 zmq::context_t context_;
170 zmq::socket_t socket_;
171
179 auto sendRequestAndReceiveReply_(zmq::message_t& request,
180 zmq::message_t& reply) noexcept -> bool;
181};
182
183#endif // CLIENT_HPP
A class to manage the API gateway operations.
Definition client.hpp:12
auto authenticateUser(const std::string &username, const std::string &password) noexcept -> bool
Authenticates a user.
auto start() noexcept -> bool
Starts the client.
auto getUserTags(const std::string &username) -> std::vector< std::string >
Gets the tags of a user.
Client(const Client &other)
Copy constructor for the Client class.
auto stop() noexcept -> bool
Stops the client.
auto removeUserTag(const std::string &username, const std::string &tag) noexcept -> bool
Removes a tag from a user.
auto operator=(const Client &other) -> Client &
Copy assignment operator for the Client class.
Client(std::string serverAddr)
Constructor for the Client class.
auto addUserTag(const std::string &username, const std::string &tag) noexcept -> bool
Adds a tag to a user.
~Client()
Destructor for the Client class.
auto sendMessage(const std::string &from, const std::string &to, const std::string &message) noexcept -> bool
Sends a message from one user to another.
Client(Client &&other) noexcept
Move constructor for the Client class.
auto operator=(Client &&other) noexcept -> Client &
Move assignment operator for the Client class.
auto listAllUsers() -> std::vector< std::string >
Gets a list of all users.
auto isExistUser(const std::string &username) noexcept -> bool
Checks if a user exists in the system.
auto getReceivedMessages(const std::string &username) -> std::vector< std::string >
Gets the messages received by a user.
auto getSentMessages(const std::string &username) -> std::vector< std::string >
Gets the messages sent by a user.
auto addUser(const std::string &username, const std::string &password) noexcept -> bool
Adds a user to the system.
auto getPair(const std::string &username) -> std::vector< std::string >
Gets the pair of a user.
auto restart() noexcept -> bool
Restarts the client.
auto removeUser(const std::string &username) noexcept -> bool
Removes a user from the system.