File tree Expand file tree Collapse file tree 5 files changed +17
-2
lines changed Expand file tree Collapse file tree 5 files changed +17
-2
lines changed Original file line number Diff line number Diff line change @@ -37,7 +37,7 @@ class Channel
37
37
~Channel ();
38
38
std::string getname ();
39
39
unsigned int get_participants ();
40
- std::vector<Client> get_clients ();
40
+ std::vector<Client>& get_clients ();
41
41
bool add_participant (Client *client);
42
42
void remove_participant (Client &client);
43
43
void send_to_channel (std::string msg, std::string nick);
Original file line number Diff line number Diff line change @@ -91,6 +91,7 @@ class IrcServer
91
91
void closeAll ();
92
92
bool checkChannelNames (std::string _name);
93
93
bool invalidChannelCharacter (std::string _nickname);
94
+ void deleteUserInChannel (std::string _nickname);
94
95
};
95
96
96
97
bool isInt (const char * str_nb);
Original file line number Diff line number Diff line change @@ -41,7 +41,7 @@ unsigned int Channel::get_participants()
41
41
return (this ->participant );
42
42
}
43
43
44
- std::vector<Client> Channel::get_clients ()
44
+ std::vector<Client>& Channel::get_clients ()
45
45
{
46
46
return (this ->clients );
47
47
}
Original file line number Diff line number Diff line change @@ -202,6 +202,7 @@ void IrcServer::deleteClients(std::vector<int>& _todelete)
202
202
std::sort (_todelete.begin (), _todelete.end ());
203
203
for (it = _todelete.rbegin () ; it != _todelete.rend () ; it++)
204
204
{
205
+ deleteUserInChannel (clients[*it - 1 ]->getNickname ());
205
206
close (fd_sockets[*it].fd );
206
207
fd_sockets.erase (fd_sockets.begin () + *it);
207
208
addr_sockets.erase (addr_sockets.begin () + *it);
Original file line number Diff line number Diff line change @@ -84,3 +84,16 @@ bool IrcServer::checkChannelNames(std::string _name)
84
84
return (false );
85
85
return (true );
86
86
}
87
+
88
+ void IrcServer::deleteUserInChannel (std::string _nickname)
89
+ {
90
+ std::vector<Channel*>::iterator it;
91
+ int pos;
92
+
93
+ for (it = channels.begin () ; it != channels.end () ; it++)
94
+ {
95
+ pos = searchUserInChannel (_nickname, (*it)->getname ());
96
+ if (pos != -1 )
97
+ (*it)->deleteMember (_nickname);
98
+ }
99
+ }
You can’t perform that action at this time.
0 commit comments