Repository navigation
Expand file tree
/
Copy pathServerErrorMessage.cpp
More file actions
88 lines (68 loc) · 2.55 KB
/
Copy pathServerErrorMessage.cpp
File metadata and controls
88 lines (68 loc) · 2.55 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
#include "Server.hpp"
void Server::replyErrToClient(int numErrno, std::string nickname, std::string channel, int sd, std::string arg){
std::string msg = "";
(void)arg;
switch (numErrno) {
case ERR_NICKNAMEINUSE:
msg += ":localhost 433 *" + nickname + " :Nickname is already in use\r\n";
break;
case ERR_UNKNOWNCOMMAND:
msg = "Unknown command.";
break;
case ERR_PASSWDMISMATCH:
msg += ":localhost 464 * :Password incorrect\r\n";
break;
case ERR_NOTONCHANNEL:
msg += ":localhost 442 " + nickname + " " + channel + " :You're not on that channel\r\n";
break;
case ERR_USERONCHANNEL:
msg += ":localhost 443 " + nickname + " " + arg + " " + channel + " :Is already on channel\r\n";
break;
case ERR_NOSUCHNICK:
msg = ":localhost 401 " + nickname + " " + channel + " :No such nick/channel\r\n";
break;
case ERR_CANNOTSENDTOCHAN:
msg = ":localhost 404 " + nickname + " " + channel + " :Cannot send to channel\r\n";
break;
case ERR_USERNOTINCHANNEL:
msg = ":localhost 441 " + nickname + " " + channel + " :User is not in that channel\r\n";
break;
case ERR_NOSUCHCHANNEL:
msg = ":localhost 403 " + nickname + " " + channel + " :No Channel found\r\n";
break;
case ERR_CHANOPRIVSNEEDED:
msg = ":localhost 482 " + nickname + " " + channel + " :You're not channel operator\r\n";
break;
case ERR_INVITEONLYCHAN:
msg = ":localhost 473 " + channel + arg + "\r\n";
break;
case ERR_NEEDMOREPARAMS:
msg = ":localhost 461 " + nickname + " " + arg + " :Not enough parameters\r\n";
break;
case ERR_BADCHANNELKEY:
msg = ":localhost 475 " + nickname + " " + channel + " :Cannot join channel (+k)\r\n";
break;
case ERR_CHANNELISFULL:
msg = ":localhost 471 " + nickname + " " + channel + " :Cannot join channel (+l)\r\n";
break;
case ERR_UNKNOWNMODE:
msg = ":localhost 472 " + nickname + " " + arg + " :Is unknown mode char to me\r\n";
break ;
case ERR_NORECIPIENT:
msg = ":localhost 411 " + nickname + " :No recipient given (" + arg + ")\r\n";
break ;
case ERR_NOTEXTTOSEND:
msg = ":localhost 412 " + nickname + " :No text to send\r\n";
break ;
case ERR_NOTREGISTERED:
msg = ":localhost 451 " + nickname + " :You have not registered\r\n";
break ;
case ERR_TOOMANYTARGETS:
msg = ":localhost 407 " + nickname + " " + channel + " :Too many targets\r\n";
break ;
default:
break;
}
std::cout << "msg to send: " << msg << std::endl;
send(sd, msg.c_str(), msg.length(), MSG_NOSIGNAL);
}