-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathClient.cpp
More file actions
76 lines (71 loc) · 2.92 KB
/
Client.cpp
File metadata and controls
76 lines (71 loc) · 2.92 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* Client.cpp :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: hlabouit <hlabouit@student.1337.ma> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/08/26 13:52:36 by frukundo #+# #+# */
/* Updated: 2024/10/02 10:26:42 by hlabouit ### ########.fr */
/* */
/* ************************************************************************** */
#include "includes/Client.hpp"
Client::Client()
{
this->nickname = "default";
this->username = "default1";
this->fd = -1;
this->isOperator= false;
this->registered = false;
this->buffer = "";
this->ipadd = "";
this->logedin = false;
}
Client::Client(std::string nickname, std::string username, int fd) :fd(fd), nickname(nickname), username(username){}
Client::~Client(){}
Client::Client(Client const &src){*this = src;}
Client &Client::operator=(Client const &src){
if (this != &src){
this->nickname = src.nickname;
this->username = src.username;
this->fd = src.fd;
this->ChannelsInvite = src.ChannelsInvite;
this->buffer = src.buffer;
this->registered = src.registered;
this->ipadd = src.ipadd;
this->logedin = src.logedin;
}
return *this;
}
int Client::GetFd(){return this->fd;}
bool Client::getRegistered(){return registered;}
bool Client::GetInviteChannel(std::string &ChName){
for (size_t i = 0; i < this->ChannelsInvite.size(); i++){
if (this->ChannelsInvite[i] == ChName)
return true;
}
return false;
}
std::string Client::GetNickName(){return this->nickname;}
bool Client::GetLogedIn(){return this->logedin;}
std::string Client::GetUserName(){return this->username;}
std::string Client::getIpAdd(){return ipadd;}
std::string Client::getAm(){
return (this->assembled_message);
}
void Client::SetFd(int fd){this->fd = fd;}
void Client::SetNickname(std::string& nickName){this->nickname = nickName;}
void Client::setLogedin(bool value){this->logedin = value;}
void Client::SetUsername(std::string& username){this->username = username;}
void Client::setRegistered(bool value){registered = value;}
void Client::setIpAdd(std::string ipadd){this->ipadd = ipadd;}
void Client::setAm(const std::string &am){this->assembled_message = am;}
void Client::AddChannelInvite(std::string &chname){
ChannelsInvite.push_back(chname);
}
void Client::RmChannelInvite(std::string &chname){
for (size_t i = 0; i < this->ChannelsInvite.size(); i++){
if (this->ChannelsInvite[i] == chname)
{this->ChannelsInvite.erase(this->ChannelsInvite.begin() + i); return;}
}
}