70 lines
2.5 KiB
C++
70 lines
2.5 KiB
C++
/******************************************************************************/
|
|
/* */
|
|
/* ::: :::::::: */
|
|
/* client.hpp :+: :+: :+: */
|
|
/* +:+ +:+ +:+ */
|
|
/* By: vvaas <vvaas@student.42angouleme.fr> +#+ +:+ +#+ */
|
|
/* +#+#+#+#+#+ +#+ */
|
|
/* Created: 2024/01/21 10:33:17 by maldavid #+# #+# */
|
|
/* Updated: 2024/01/24 00:11:46 by vvaas ### ########.fr */
|
|
/* */
|
|
/******************************************************************************/
|
|
|
|
#ifndef __CLIENT__
|
|
#define __CLIENT__
|
|
|
|
#include <irc.hpp>
|
|
#include <string>
|
|
|
|
namespace irc
|
|
{
|
|
class Client
|
|
{
|
|
public:
|
|
Client(int fd, sockaddr_in sock, int id);
|
|
|
|
inline void newMsgInFlight(const std::string& msg) { _msg_in_flight = msg; }
|
|
|
|
inline int getFD() const { return _fd; }
|
|
inline int getID() const { return _id; }
|
|
inline int getLogged() const { return _logged; }
|
|
inline int getDisconnect() const { return _to_disconnect; }
|
|
inline sockaddr_in getSockAddr() const { return _s_data; }
|
|
inline const std::string& getMsgInFlight() const { return _msg_in_flight; }
|
|
|
|
std::string getNextMsg();
|
|
|
|
inline void setNewNickName(const std::string& name) { _nickname = name; }
|
|
inline void setNewUserName(const std::string& name) { _username = name; }
|
|
inline void setNewRealName(const std::string& name) { _realname = name; }
|
|
inline void setLogged(void) { _logged = true; }
|
|
inline void setDisconnect(void) { _to_disconnect = true; }
|
|
|
|
inline const std::string& getNickName() const { return _nickname; }
|
|
inline const std::string& getUserName() const { return _username; }
|
|
inline const std::string& getRealName() const { return _realname; }
|
|
|
|
void printUserHeader() const;
|
|
|
|
inline void setFd(int new_fd) { _fd = new_fd; }
|
|
|
|
void sendCode(const std::string& code, const std::string& msg);
|
|
void sendMsg(const std::string& sender, const std::string& cmd, const std::string& trailing);
|
|
|
|
~Client();
|
|
|
|
private:
|
|
std::string _nickname;
|
|
std::string _username;
|
|
std::string _realname;
|
|
std::string _msg_in_flight;
|
|
sockaddr_in _s_data;
|
|
int _fd;
|
|
int _id;
|
|
bool _logged;
|
|
bool _to_disconnect;
|
|
};
|
|
}
|
|
|
|
#endif
|