-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathClient.cpp
More file actions
102 lines (73 loc) · 3.19 KB
/
Copy pathClient.cpp
File metadata and controls
102 lines (73 loc) · 3.19 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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* Client.cpp :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: anmohamm <[email protected] +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/10/06 16:31:30 by anmohamm #+# #+# */
/* Updated: 2024/10/06 16:31:30 by anmohamm ### ########.fr */
/* */
/* ************************************************************************** */
#include "Client.hpp"
Client::Client(){
this->nickname = "";
this->username = "";
this->fd = -1;
this->isOperator= false;
this->registered = false;
this->buffer = "";
this->ip_address = "";
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->ip_address = src.ip_address;
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::getBuffer(){return buffer;}
std::string Client::getIpAddress(){return ip_address;}
std::string Client::getHostname(){
std::string hostname = this->GetNickName() + "!" + this->GetUserName();
return hostname;
}
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::setBuffer(std::string recived){buffer += recived;}
void Client::setRegistered(bool value){registered = value;}
void Client::setIpAddress(std::string ipadd){this->ip_address = ipadd;}
void Client::clearBuffer(){buffer.clear();}
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;}
}
}