GameRC (IRC Server)  1.0.0
C++98 기반 IRC 서버 프로젝트
로딩중...
검색중...
일치하는것 없음
IRC.hpp
이 파일의 문서화 페이지로 가기
1/**
2 * @file IRC.hpp
3 * @author Taeil-Nam (nam0314@gmail.com)
4 * @brief IRC 매크로 및 IRC 클래스 정의 헤더 파일.
5 * @version 0.1
6 * @date 2024-03-31
7 *
8 * @copyright Copyright (c) 2024
9 *
10 */
11
12#pragma once
13
14#include "common.hpp"
15#include "UserManager.hpp"
16#include "ChannelManager.hpp"
17
18using namespace gdf;
19
20/**
21 * @brief
22 * IRC 서버의 버전을 나타내는 매크로.
23 */
24#define IRC_VERSION "v0.1"
25
26/**
27 * @brief Carriage Return Line Feed(CRLF)를 나타내는 매크로.
28 */
29#define CRLF "\r\n"
30
31////////////////////////////////////////////////////////////
32// Error Replies
33////////////////////////////////////////////////////////////
34
35/**
36 * @brief 해당 nick을 가진 유저가 없는 경우 응답하는 에러 코드.
37 *
38 * 메시지 형식: "<client> <nick> :No such nick/channel"
39 */
40#define ERR_NOSUCHNICK "401"
41
42/**
43 * @brief 해당 channel name을 가진 채널이 없는 경우 응답하는 에러 코드.
44 *
45 * 메시지 형식: "<channel name> :No such channel"
46 */
47#define ERR_NOSUCHCHANNEL "403"
48
49/**
50 * @brief PRIVMSG에 받는 사람이 없는 경우 응답하는 에러 코드.
51 *
52 * 메시지 형식: "<client> :No recipient given (<command>)"
53 */
54#define ERR_NORECIPIENT "411"
55
56/**
57 * @brief PRIVMSG에 전달할 메시지 내용이 없는 경우 응답하는 에러 코드.
58 *
59 * 메시지 형식: "<client> :No text to send"
60 */
61#define ERR_NOTEXTTOSEND "412"
62
63/**
64 * @brief PRIVMSG / NOTICE 메시지가 주어진 채널에 전달될 수 없을 때 응답하는 에러 코드.
65 * 유저가 채널에 메시지를 보낼 수 있는 권한이 없거나, 채널에 입장되어 있는 상태가 아닌 경우에 해당된다.
66 *
67 * 메시지 형식: "<client> <channel> :Cannot send to channel"
68 */
69#define ERR_CANNOTSENDTOCHAN "404"
70
71/**
72 * @brief 서버의 Message of the Day(MOTD) 파일이 존재하지 않는 경우 응답하는 에러 코드.
73 *
74 * 메시지 형식: "<client> :MOTD File is missing"
75 */
76#define ERR_NOMOTD "422"
77
78/**
79 * @brief nick이 꼭 필요한 메시지에 nick이 없는 경우 응답하는 에러 코드.
80 *
81 * 메시지 형식: ":No nick given"
82 */
83#define ERR_NONICKNAMEGIVEN "431"
84
85/**
86 * @brief NICK 메시지의 nick에 사용할 수 없는 문자가 들어있는 경우 응답하는 에러 코드.
87 *
88 * 메시지 형식: "<nick> :Erroneus nick"
89 */
90#define ERR_ERRONEUSNICKNAME "432"
91
92/**
93 * @brief NICK 메시지의 nick을 이미 다른 유저가 사용하고 있는 경우 응답하는 에러 코드.
94 *
95 * 메시지 형식: "<nick> :nick is already in use"
96 */
97#define ERR_NICKNAMEINUSE "433"
98
99/**
100 * @brief channel + nick의 조합을 사용하는 메시지에서, 해당 nick이 채널에 없는 경우 응답하는 에러 코드.
101 *
102 * 메시지 형식: "<client> <nick> <channel> :They aren't on that channel"
103 */
104#define ERR_USERNOTINCHANNEL "441"
105
106/**
107 * @brief user가 속하지 않은 채널에 특정 메시지를 전달하려고 하는 경우 응답하는 에러 코드.
108 *
109 * 메시지 형식: "<client> <channel> :You're not on that channel"
110 */
111#define ERR_NOTONCHANNEL "442"
112
113/**
114 * @brief 채널에 이미 있는 nick을 초대했을 경우 응답하는 에러 코드.
115 *
116 * 메시지 형식: "<client> <nick> <channel> :is already on channel"
117 */
118#define ERR_USERONCHANNEL "443"
119
120/**
121 * @brief 메시지에 필요한 매개변수가 부족한 경우 응답하는 에러 코드.
122 *
123 * 메시지 형식: "<command> :Not enough parameters"
124 */
125#define ERR_NEEDMOREPARAMS "461"
126
127/**
128 * @brief 연결 등록이 되지 않은 user로부터 메시지를 받은 경우 응답하는 에러 코드.
129 *
130 * 메시지 형식: ":You may not reregister"
131 */
132#define ERR_ALREADYREGISTERED "462"
133
134/**
135 * @brief 연결 등록을 위한 password가 다른 경우 응답하는 에러 코드.
136 *
137 * 메시지 형식: ":Password incorrect"
138 */
139#define ERR_PASSWDMISMATCH "464"
140
141/**
142 * @brief 유저가 가득찬 채널에 입장하려고 하는 경우 응답하는 에러 코드.
143 *
144 * 메시지 형식: "<channel> :Cannot join channel (+l)"
145 */
146#define ERR_CHANNELISFULL "471"
147
148/**
149 * @brief 유저가 초대를 받지 않고 초대 전용 채널에 입장하는 경우 응답하는 에러 코드.
150 *
151 * 메시지 형식: "<channel> :Cannot join channel (+i)"
152 */
153#define ERR_INVITEONLYCHAN "473"
154
155/**
156 * @brief 채널 입장에 필요한 key(password)가 없거나 다른 경우 응답하는 에러 코드.
157 *
158 * 메시지 형식: "<channel> :Cannot join channel (+k)"
159 */
160#define ERR_BADCHANNELKEY "475"
161
162/**
163 * @brief operator 권한이 없는 user가 operator 권한이 필요한 메시지를 사용하는 경우 응답하는 에러 코드.
164 *
165 * 메시지 형식: "<client> <channel> :You're not channel operator"
166 */
167#define ERR_CHANOPRIVSNEEDED "482"
168
169////////////////////////////////////////////////////////////
170// Command responses.
171////////////////////////////////////////////////////////////
172
173/**
174 * @brief user가 등록되면 첫 번째로 응답하는 메시지이며, 해당 user의 정보를 알려준다.
175 *
176 * 메시지 형식: "<nick> :Welcome to the <networkname> Network, <nick>[!<user>@<host>]"
177 */
178#define RPL_WELCOME "001"
179
180/**
181 * @brief user가 등록되면 두 번째로 응답하는 메시지이며, 해당 user가 연결된 서버의 정보를 알려준다.
182 *
183 * 메시지 형식: "<nick> :Your host is <servername>, running version <version>"
184 */
185#define RPL_YOURHOST "002"
186
187/**
188 * @brief user가 등록되면 세 번째로 응답하는 메시지이며, 해당 user가 연결된 서버가 생성된 날짜를 알려준다.
189 *
190 * 메시지 형식: "<nick> :This server was created <datetime>"
191 */
192#define RPL_CREATED "003"
193
194/**
195 * @brief user가 등록되면 네 번째로 응답하는 메시지이며, 서버 이름 및 version을 알려준다.
196 *
197 * 메시지 형식: "<nick> <servername> <version> <available user modes> ""
198 */
199#define RPL_MYINFO "004"
200
201/**
202 * @brief user가 등록되면 다섯 번째로 응답하는 메시지이며, 서버에서 지원 가능한 목록들을 알려준다.
203 *
204 * 메시지 형식: "<nick> <1-13 tokens> :are supported by this server"
205 */
206#define RPL_ISUPPORT "005"
207
208/**
209 * @brief 현재 채널에 어떤 mode가 적용되어 있는지 알려준다.
210 *
211 * 메시지 형식: "<nick> <channel> <modestring> <mode arguments>..."
212 */
213#define RPL_CHANNELMODEIS "324"
214
215/**
216 * @brief 유저가 채널에 입장했을 때, 채널에 topic이 없는 경우 topic이 설정되어 있지 않다고 알려준다.
217 *
218 * 메시지 형식: "<nick> <channel> :No topic is set"
219 */
220#define RPL_NOTOPIC "331"
221
222/**
223 * @brief 유저가 채널에 입장했을 때, 채널에 topic이 있는 경우 topic을 알려준다.
224 *
225 * 메시지 형식: "<nick> <channel> :<topic>"
226 */
227#define RPL_TOPIC "332"
228
229/**
230 * @brief 유저가 특정 유저를 채널에 초대했을 때, 정상적으로 초대했음을 알려준다.
231 *
232 * 메시지 형식: "<client> <target nick> <channel>"
233 */
234#define RPL_INVITING "341"
235
236/**
237 * @brief 채널의 모든 유저 목록을 알려준다.
238 *
239 * 메시지 형식: "<client> <symbol> <channel> :[[@|+]<nick> [[@|+]<nick> [...]]]"
240 */
241#define RPL_NAMREPLY "353"
242
243/**
244 * @brief 채널의 모든 유저 목록의 끝을 알려준다.
245 * RPL_NAMREPLY 메시지의 뒤에 따라온다.
246 *
247 * 메시지 형식: "<client> <channel> :End of /NAMES list"
248 */
249#define RPL_ENDOFNAMES "366"
250
251namespace grc
252{
253
254 /**
255 * @class IRC
256 * @brief IRC 로직을 수행하는 정적 클래스.
257 *
258 */
259 class IRC
260 {
261 public:
262 /**
263 * @brief 유저로부터 들어온 메시지를 처리하는 함수.
264 *
265 * 네트워크를 통해 수신된 메시지가 있는 경우, Core::Run()에서 호출된다.\n
266 * CRLF로 끝나는 메시지를 하나씩 가져와서 command, parameters, trailing 으로 파싱한다.\n
267 * command에 알맞는 함수를 호출한다.\n
268 *
269 * @param socket 메시지를 보낸 유저의 소켓.
270 * @param network 메시지 처리에 사용될 네트워크 객체.
271 * @param password 유저 연결 등록에 필요한 비밀번호.
272 */
273 static void HandleMessage(const int32 IN socket, Network &IN network, const std::string &IN password);
274
275 private:
276 /**
277 * @brief IRC 객체의 기본 생성자. (사용되지 않음)
278 *
279 */
280 IRC(); // = delete
281 /**
282 * @brief command 함수 포인터를 정의.
283 *
284 */
285 typedef void (*TcommandFunctionPTR)(const int32,
286 const std::string &,
287 const std::vector<std::string> &,
288 const std::string &,
289 const std::string &,
290 Network &);
291 /**
292 * @brief 정적 멤버 변수 sStaticCommandFunctionMap를 초기화하는 함수.
293 *
294 */
295 static void initializeCommandFunctionMap();
296 /**
297 * @brief CRLF로 끝나는 메시지를 파싱하는 함수.
298 *
299 * 메시지 파싱 후 매개 변수로 받은 command, parameters, trailing에 올바른 값들을 넣어준다.
300 *
301 * [Input message format]\n
302 * <command> <parameters> <trailing>\n
303 * <trailing> = ':'로 시작하는 맨 마지막 문자열.
304 *
305 * @param message 원본 메시지.
306 * @param command command가 저장되는 std::string.
307 * @param parameters parameter들이 저장되는 std::vector<std::string>.
308 * @param trailing trailing이 저장되는 std::string.
309 */
310 static void parseMessage(const std::string &IN message,
311 std::string &OUT command,
312 std::vector<std::string> &OUT parameters,
313 std::string &OUT trailing);
314 /**
315 * @brief PASS 메시지를 처리하는 함수.
316 *
317 * 유저를 인증한다.
318 *
319 * [Error Replies]\n
320 * - ERR_NEEDMOREPARAMS : parameter가 부족한 경우.\n
321 * - ERR_PASSWDMISMATCH : password가 다른 경우.\n
322 * - ERR_ALREADYREGISTERED : 유저가 이미 등록되어 있는 경우.\n
323 *
324 * @param socket 메시지를 보낸 유저의 소켓.
325 * @param command command.
326 * @param parameters parameters.
327 * @param trailing trailing.
328 * @param password 유저 연결 등록에 필요한 비밀번호.
329 * @param network 메시지 처리에 사용될 네트워크 객체.
330 */
331 static void PASS(const int32 IN socket,
332 const std::string &IN command,
333 const std::vector<std::string> &IN parameters,
334 const std::string &IN trailing,
335 const std::string &IN password,
336 Network &IN OUT network);
337 /**
338 * @brief NICK 메시지를 처리하는 함수.
339 *
340 * 유저의 nickname을 설정한다.
341 *
342 * nickname이 올바르게 설정된 경우, 해당 유저가 속한 모든 채널에 알린다.
343 *
344 * [Error Replies]\n
345 * - ERR_NONICKNAMEGIVEN : 메시지에 nickname이 없는 경우.\n
346 * - ERR_ERRONEUSNICKNAME : 사용할 수 없는 문자가 nickname에 포함되어 있는 경우.\n
347 * - ERR_NICKNAMEINUSE : 이미 해당 nickname을 사용하는 유저가 있는 경우.\n
348 *
349 * @param socket 메시지를 보낸 유저의 소켓.
350 * @param command command.
351 * @param parameters parameters.
352 * @param trailing trailing.
353 * @param password 사용되지 않음.
354 * @param network 메시지 처리에 사용될 네트워크 객체.
355 */
356 static void NICK(const int32 IN socket,
357 const std::string &IN command,
358 const std::vector<std::string> &IN parameters,
359 const std::string &IN trailing,
360 const std::string &IN password,
361 Network &IN OUT network);
362 /**
363 * @brief USER 메시지를 처리하는 함수.
364 *
365 * 유저의 username, hostname, servername, realname을 설정한다.
366 *
367 * 유저 설정을 마친 후, 유저가 연결되었는지 확인을 위해 PING 메시지를 전송한다.\n
368 * 유저가 PING 메시지에 대한 PONG 메시지를 응답한 경우, 해당 유저의 연결을 등록한다.
369 *
370 * [Error Replies]\n
371 * - ERR_NEEDMOREPARAMS : parameter가 부족한 경우.\n
372 * - ERR_ALREADYREGISTERED : 이미 유저가 등록된 경우.\n
373 *
374 * @param socket 메시지를 보낸 유저의 소켓.
375 * @param command command.
376 * @param parameters parameters.
377 * @param trailing trailing.
378 * @param password 사용되지 않음.
379 * @param network 메시지 처리에 사용될 네트워크 객체.
380 */
381 static void USER(const int32 IN socket,
382 const std::string &IN command,
383 const std::vector<std::string> &IN parameters,
384 const std::string &IN trailing,
385 const std::string &IN password,
386 Network &IN OUT network);
387 /**
388 * @brief QUIT 메시지를 처리하는 함수.
389 *
390 * 유저를 종료시킨다.
391 *
392 * 유저가 특정 채널에 존재하는 경우, 해당 채널에 유저가 종료되었음을 알린다.
393 *
394 * @param socket 메시지를 보낸 유저의 소켓.
395 * @param command command.
396 * @param parameters parameters.
397 * @param trailing trailing.
398 * @param password 사용되지 않음.
399 * @param network 메시지 처리에 사용될 네트워크 객체.
400 */
401 static void QUIT(const int32 IN socket,
402 const std::string &IN command,
403 const std::vector<std::string> &IN parameters,
404 const std::string &IN trailing,
405 const std::string &IN password,
406 Network &IN OUT network);
407 /**
408 * @brief JOIN 메시지를 처리하는 함수.
409 *
410 * 유저를 특정 채널에 입장시킨다.
411 *
412 * 유저가 새로운 채널에 입장하는 경우, 채널의 operator로 설정된다.\n
413 * 유저가 기존 채널에 입장하는 경우, 채널의 일반 유저로 설정된다.\n
414 * 채널의 모든 유저에게 새로운 유저의 입장을 알린다.
415 *
416 * [Error Replies]\n
417 * - ERR_NEEDMOREPARAMS : parameter가 부족한 경우.\n
418 * - ERR_INVITEONLYCHAN : 채널이 초대 전용으로 설정되어 있으나, 초대 받지 않은 상태인 경우.\n
419 * - ERR_BADCHANNELKEY : 채널에 key가 설정되어 있으나, 올바르지 않은 key로 입장한 경우.\n
420 * - ERR_CHANNELISULL : 채널이 꽉 찬 경우.
421 *
422 * @param socket 메시지를 보낸 유저의 소켓.
423 * @param command command.
424 * @param parameters parameters.
425 * @param trailing trailing.
426 * @param password 사용되지 않음.
427 * @param network 메시지 처리에 사용될 네트워크 객체.
428 */
429 static void JOIN(const int32 IN socket,
430 const std::string &IN command,
431 const std::vector<std::string> &IN parameters,
432 const std::string &IN trailing,
433 const std::string &IN password,
434 Network &IN OUT network);
435 /**
436 * @brief PART 메시지를 처리하는 함수.
437 *
438 * 유저를 채널에서 퇴장시킨다.
439 *
440 * 채널의 모든 유저에게 유저의 퇴장을 알린다.
441 *
442 * [Error Replies]\n
443 * - ERR_NEEDMOREPARAMS : parameter가 부족한 경우.\n
444 * - ERR_NOSUCHCHANNEL : 없는 채널인 경우.\n
445 * - ERR_NOTONCHANNEL : 유저가 채널에 없는 경우.\n
446 *
447 * @param socket 메시지를 보낸 유저의 소켓.
448 * @param command command.
449 * @param parameters parameters.
450 * @param trailing trailing.
451 * @param password 사용되지 않음.
452 * @param network 메시지 처리에 사용될 네트워크 객체.
453 */
454 static void PART(const int32 IN socket,
455 const std::string &IN command,
456 const std::vector<std::string> &IN parameters,
457 const std::string &IN trailing,
458 const std::string &IN password,
459 Network &IN OUT network);
460 /**
461 * @brief MODE 메시지를 처리하는 함수.
462 *
463 * 채널에 대한 옵션을 설정한다.
464 *
465 * 옵션 설정 후, 채널의 모든 유저에게 알린다.
466 *
467 * [Options]\n
468 * - o : 특정 유저에게 채널의 operator 권한을 부여하거나 해제한다.\n
469 * - t : 채널의 topic 변경을 operator만 가능하도록 설정하거나 해제한다.\n
470 * - i : 채널을 초대 전용으로 설정하거나 해제한다.\n
471 * - l : 채널의 최대 유저 수를 설정하거나 해제한다.\n
472 * - k : 채널 입장에 필요한 key(password)를 설정하거나 해제한다.
473 *
474 * [Error Replies]\n
475 * - ERR_NEEDMOREPARAMS : parameter가 부족한 경우.\n
476 * - ERR_NOSUCHCHANNEL : 없는 채널인 경우.\n
477 * - ERR_CHANOPRIVSNEEDED : 메시지를 보낸 유저가 operator가 아닌 경우.\n
478 *
479 * @param socket 메시지를 보낸 유저의 소켓.
480 * @param command command.
481 * @param parameters parameters.
482 * @param trailing trailing.
483 * @param password 사용되지 않음.
484 * @param network 메시지 처리에 사용될 네트워크 객체.
485 */
486 static void MODE(const int32 IN socket,
487 const std::string &IN command,
488 const std::vector<std::string> &IN parameters,
489 const std::string &IN trailing,
490 const std::string &IN password,
491 Network &IN OUT network);
492 /**
493 * @brief TOPIC 메시지를 처리하는 함수.
494 *
495 * 채널의 topic을 설정하거나 삭제한다.\n
496 * trailing이 없는 경우, 채널의 topic을 알려준다.
497 *
498 * topic 설정 및 삭제 후, 채널의 모든 유저에게 알린다.
499 *
500 * [Error Replies]\n
501 * - ERR_NEEDMOREPARAMS : parameter가 부족한 경우.\n
502 * - ERR_NOSUCHCHANNEL : 없는 채널인 경우.\n
503 * - ERR_NOTONCHANNEL : 유저가 채널에 없는 경우.\n
504 * - ERR_CHANOPRIVSNEEDED : 메시지를 보낸 유저가 operator가 아닌 경우.
505 *
506 * @param socket 메시지를 보낸 유저의 소켓.
507 * @param command command.
508 * @param parameters parameters.
509 * @param trailing trailing.
510 * @param password 사용되지 않음.
511 * @param network 메시지 처리에 사용될 네트워크 객체.
512 */
513 static void TOPIC(const int32 IN socket,
514 const std::string &IN command,
515 const std::vector<std::string> &IN parameters,
516 const std::string &IN trailing,
517 const std::string &IN password,
518 Network &IN OUT network);
519 /**
520 * @brief INVITE 메시지를 처리하는 함수.
521 *
522 * 특정 유저를 채널에 초대한다.\n
523 *
524 * [Error Replies]\n
525 * - ERR_NEEDMOREPARAMS : parameter가 부족한 경우.\n
526 * - ERR_NOSUCHCHANNEL : 없는 채널인 경우.\n
527 * - ERR_NOTONCHANNEL : 유저가 채널에 없는 경우.\n
528 * - ERR_CHANOPRIVSNEEDED : 메시지를 보낸 유저가 operator가 아닌 경우.\n
529 * - ERR_USERONCHANNEL : 유저가 이미 채널에 존재하는 경우.
530 *
531 * @param socket 메시지를 보낸 유저의 소켓.
532 * @param command command.
533 * @param parameters parameters.
534 * @param trailing trailing.
535 * @param password 사용되지 않음.
536 * @param network 메시지 처리에 사용될 네트워크 객체.
537 */
538 static void INVITE(const int32 IN socket,
539 const std::string &IN command,
540 const std::vector<std::string> &IN parameters,
541 const std::string &IN trailing,
542 const std::string &IN password,
543 Network &IN OUT network);
544 /**
545 * @brief KICK 메시지를 처리하는 함수.
546 *
547 * 특정 유저를 채널에서 강제로 추방시킨다.
548 *
549 * 유저 추방 후, 채널의 모든 유저에게 알린다.
550 *
551 * [Error Replies]\n
552 * - ERR_NEEDMOREPARAMS : parameter가 부족한 경우.\n
553 * - ERR_NOSUCHCHANNEL : 없는 채널인 경우.\n
554 * - ERR_NOTONCHANNEL : 유저가 채널에 없는 경우.\n
555 * - ERR_CHANOPRIVSNEEDED : 메시지를 보낸 유저가 operator가 아닌 경우.\n
556 * - ERR_USERNOTINCHANNEL : 추방시킬 유저가 채널에 존재하지 않는 경우.
557 *
558 * @param socket 메시지를 보낸 유저의 소켓.
559 * @param command command.
560 * @param parameters parameters.
561 * @param trailing trailing.
562 * @param password 사용되지 않음.
563 * @param network 메시지 처리에 사용될 네트워크 객체.
564 */
565 static void KICK(const int32 IN socket,
566 const std::string &IN command,
567 const std::vector<std::string> &IN parameters,
568 const std::string &IN trailing,
569 const std::string &IN password,
570 Network &IN OUT network);
571 /**
572 * @brief PRIVMSG 메시지를 처리하는 함수.
573 *
574 * 유저 또는 채널에 메시지를 전송한다.
575 *
576 * [Error Replies]\n
577 * - ERR_NORECIPIENT : 메시지를 전달할 목적지가 포함되어 있지 않은 경우.\n
578 * - ERR_NOTEXTTOSEND : 전달할 메시지가 포함되어 있지 않은 경우.\n
579 * - ERR_CANNOTSENDTOCHAN : 메시지를 보내는 유저가 해당 채널에 없는 경우.\n
580 * - ERR_NOSUCHNICK : 메시지를 전송할 유저나 채널 이름이 존재하지 않는 경우.\n
581 *
582 * @param socket 메시지를 보낸 유저의 소켓.
583 * @param command command.
584 * @param parameters parameters.
585 * @param trailing trailing.
586 * @param password 사용되지 않음.
587 * @param network 메시지 처리에 사용될 네트워크 객체.
588 */
589 static void PRIVMSG(const int32 IN socket,
590 const std::string &IN command,
591 const std::vector<std::string> &IN parameters,
592 const std::string &IN trailing,
593 const std::string &IN password,
594 Network &IN OUT network);
595 /**
596 * @brief PING 메시지를 처리하는 함수.
597 *
598 * PING 메시지를 보낸 유저에게 PONG 메시지를 전송한다.
599 *
600 * @param socket 메시지를 보낸 유저의 소켓.
601 * @param command command.
602 * @param parameters parameters.
603 * @param trailing trailing.
604 * @param password 사용되지 않음.
605 * @param network 메시지 처리에 사용될 네트워크 객체.
606 */
607 static void PING(const int32 IN socket,
608 const std::string &IN command,
609 const std::vector<std::string> &IN parameters,
610 const std::string &IN trailing,
611 const std::string &IN password,
612 Network &IN OUT network);
613 /**
614 * @brief PONG 메시지를 처리하는 함수.
615 *
616 * 유저가 PONG 메시지를 보낸 경우, 해당 유저를 등록시킨다.
617 *
618 * @param socket 메시지를 보낸 유저의 소켓.
619 * @param command command.
620 * @param parameters parameters.
621 * @param trailing trailing.
622 * @param password 사용되지 않음.
623 * @param network 메시지 처리에 사용될 네트워크 객체.
624 */
625 static void PONG(const int32 IN socket,
626 const std::string &IN command,
627 const std::vector<std::string> &IN parameters,
628 const std::string &IN trailing,
629 const std::string &IN password,
630 Network &IN OUT network);
631
632 /**
633 * @brief 웰컴 메시지를 전송하는 함수.
634 *
635 * 유저가 등록되면, 웰컴 메시지를 전송한다.
636 *
637 * @param socket 메시지를 보낸 유저의 소켓.
638 * @param network 메시지 처리에 사용될 네트워크 객체.
639 */
640 static void sendWelcomeMessage(const int32 IN socket, Network &IN OUT network);
641 /**
642 * @brief nickname 중복을 확인하는 함수.
643 *
644 * @param nickname 찾을 nickname.
645 * @return true nickname이 이미 사용 중인 경우, true 반환.
646 * @return false nickname이 사용 중이지 않은 경우, false 반환.
647 */
648 static bool isNicknameInUse(const std::string &IN nickname);
649
650 private:
651 /**
652 * @brief IRC command에 따라 호출해야 하는 함수를 가지고 있는 정적 멤버 변수.
653 *
654 * Key = IRC command, Value = command의 함수.
655 */
656 static std::map<std::string, TcommandFunctionPTR> sStaticCommandFunctionMap;
657 };
658
659}
ChannelManager 클래스 정의 헤더 파일.
UserManager 클래스 정의 헤더 파일.
IRC 로직을 수행하는 정적 클래스.
Definition IRC.hpp:260
static void JOIN(const int32 IN socket, const std::string &IN command, const std::vector< std::string > &IN parameters, const std::string &IN trailing, const std::string &IN password, Network &IN OUT network)
JOIN 메시지를 처리하는 함수.
Definition IRC.cpp:373
static void parseMessage(const std::string &IN message, std::string &OUT command, std::vector< std::string > &OUT parameters, std::string &OUT trailing)
CRLF로 끝나는 메시지를 파싱하는 함수.
Definition IRC.cpp:65
void(* TcommandFunctionPTR)(const int32, const std::string &, const std::vector< std::string > &, const std::string &, const std::string &, Network &)
command 함수 포인터를 정의.
Definition IRC.hpp:285
static void PING(const int32 IN socket, const std::string &IN command, const std::vector< std::string > &IN parameters, const std::string &IN trailing, const std::string &IN password, Network &IN OUT network)
PING 메시지를 처리하는 함수.
Definition IRC.cpp:1421
static bool isNicknameInUse(const std::string &IN nickname)
nickname 중복을 확인하는 함수.
Definition IRC.cpp:1547
static void KICK(const int32 IN socket, const std::string &IN command, const std::vector< std::string > &IN parameters, const std::string &IN trailing, const std::string &IN password, Network &IN OUT network)
KICK 메시지를 처리하는 함수.
Definition IRC.cpp:1183
static void INVITE(const int32 IN socket, const std::string &IN command, const std::vector< std::string > &IN parameters, const std::string &IN trailing, const std::string &IN password, Network &IN OUT network)
INVITE 메시지를 처리하는 함수.
Definition IRC.cpp:1062
IRC()
IRC 객체의 기본 생성자.
static void initializeCommandFunctionMap()
정적 멤버 변수 sStaticCommandFunctionMap를 초기화하는 함수.
Definition IRC.cpp:48
static void QUIT(const int32 IN socket, const std::string &IN command, const std::vector< std::string > &IN parameters, const std::string &IN trailing, const std::string &IN password, Network &IN OUT network)
QUIT 메시지를 처리하는 함수.
Definition IRC.cpp:312
static void HandleMessage(const int32 IN socket, Network &IN network, const std::string &IN password)
유저로부터 들어온 메시지를 처리하는 함수.
Definition IRC.cpp:11
static void PART(const int32 IN socket, const std::string &IN command, const std::vector< std::string > &IN parameters, const std::string &IN trailing, const std::string &IN password, Network &IN OUT network)
PART 메시지를 처리하는 함수.
Definition IRC.cpp:566
static void TOPIC(const int32 IN socket, const std::string &IN command, const std::vector< std::string > &IN parameters, const std::string &IN trailing, const std::string &IN password, Network &IN OUT network)
TOPIC 메시지를 처리하는 함수.
Definition IRC.cpp:923
static void PONG(const int32 IN socket, const std::string &IN command, const std::vector< std::string > &IN parameters, const std::string &IN trailing, const std::string &IN password, Network &IN OUT network)
PONG 메시지를 처리하는 함수.
Definition IRC.cpp:1443
static void MODE(const int32 IN socket, const std::string &IN command, const std::vector< std::string > &IN parameters, const std::string &IN trailing, const std::string &IN password, Network &IN OUT network)
MODE 메시지를 처리하는 함수.
Definition IRC.cpp:665
static void NICK(const int32 IN socket, const std::string &IN command, const std::vector< std::string > &IN parameters, const std::string &IN trailing, const std::string &IN password, Network &IN OUT network)
NICK 메시지를 처리하는 함수.
Definition IRC.cpp:155
static void PASS(const int32 IN socket, const std::string &IN command, const std::vector< std::string > &IN parameters, const std::string &IN trailing, const std::string &IN password, Network &IN OUT network)
PASS 메시지를 처리하는 함수.
Definition IRC.cpp:97
static void PRIVMSG(const int32 IN socket, const std::string &IN command, const std::vector< std::string > &IN parameters, const std::string &IN trailing, const std::string &IN password, Network &IN OUT network)
PRIVMSG 메시지를 처리하는 함수.
Definition IRC.cpp:1301
static std::map< std::string, TcommandFunctionPTR > sStaticCommandFunctionMap
IRC command에 따라 호출해야 하는 함수를 가지고 있는 정적 멤버 변수.
Definition IRC.hpp:656
static void USER(const int32 IN socket, const std::string &IN command, const std::vector< std::string > &IN parameters, const std::string &IN trailing, const std::string &IN password, Network &IN OUT network)
USER 메시지를 처리하는 함수.
Definition IRC.cpp:263
static void sendWelcomeMessage(const int32 IN socket, Network &IN OUT network)
웰컴 메시지를 전송하는 함수.
Definition IRC.cpp:1462
Definition Earth.cpp:12