#include <Server.hpp>
|
static EIrcErrorCode | CreateServer (Server **outPtrServer, const std::string &serverName, const unsigned short port, const std::string &password) |
| Create a server instance.
|
|
|
Execute and reply the client command.
Each function handles permission and validity checks, execution, and all replies.
|
IRC::EIrcErrorCode | executeClientCommand_PASS (SharedPtr< ClientControlBlock > client, const std::vector< char * > &arguments) |
|
IRC::EIrcErrorCode | executeClientCommand_NICK (SharedPtr< ClientControlBlock > client, const std::vector< char * > &arguments) |
|
IRC::EIrcErrorCode | executeClientCommand_USER (SharedPtr< ClientControlBlock > client, const std::vector< char * > &arguments) |
|
IRC::EIrcErrorCode | executeClientCommand_JOIN (SharedPtr< ClientControlBlock > client, const std::vector< char * > &arguments) |
|
IRC::EIrcErrorCode | executeClientCommand_MODE (SharedPtr< ClientControlBlock > client, const std::vector< char * > &arguments) |
|
IRC::EIrcErrorCode | executeClientCommand_PRIVMSG (SharedPtr< ClientControlBlock > client, const std::vector< char * > &arguments) |
|
IRC::EIrcErrorCode | executeClientCommand_TOPIC (SharedPtr< ClientControlBlock > client, const std::vector< char * > &arguments) |
|
IRC::EIrcErrorCode | executeClientCommand_KICK (SharedPtr< ClientControlBlock > client, const std::vector< char * > &arguments) |
|
IRC::EIrcErrorCode | executeClientCommand_INVITE (SharedPtr< ClientControlBlock > client, const std::vector< char * > &arguments) |
|
IRC::EIrcErrorCode | executeClientCommand_QUIT (SharedPtr< ClientControlBlock > client, const std::vector< char * > &arguments) |
|
IRC::EIrcErrorCode | executeClientCommand_PART (SharedPtr< ClientControlBlock > client, const std::vector< char * > &arguments) |
|
- Note
- See [ Server Event Loop Process Flow ] before reading implementation details.
◆ ClientCommandFuncPtr
Client command execution function type.
- See also
- ClientCommandExecution section in IRC::Server class
◆ ~Server()
◆ Server()
IRC::Server::Server |
( |
const std::string & | serverName, |
|
|
const unsigned short | port, |
|
|
const std::string & | password ) |
|
private |
◆ CreateServer()
EIrcErrorCode IRC::Server::CreateServer |
( |
Server ** | outPtrServer, |
|
|
const std::string & | serverName, |
|
|
const unsigned short | port, |
|
|
const std::string & | password ) |
|
static |
Create a server instance.
- Parameters
-
◆ Startup()
Initialize resources and start the server event loop.
Initialize kqueue and resources and register listen socket to kqueue. And then call eventLoop() to start the server.
- Note
- Blocking until the server is terminated.
- All non-static methods must be called after this function is called.
◆ operator=()
- Warning
- Copy constructor is not allowed.
◆ eventLoop()
A main event loop of the server.
◆ destroyResources()
Destroy all resources of the server.
- Note
- After calling this function, the server instance is no longer available.
◆ separateMsgsFromClientRecvMsgs()
◆ processClientMsg()
Execute and reply the client's single message.
- Parameters
-
client | The client to process the message. |
msg | The single message to process. It contains CR-LF. And it will be modified during the processing. |
- See also
- Reply message making functions
◆ getClientFromKeventUdata()
◆ executeClientCommand_PASS()
- Parameters
-
client | [in] The client to process the command. |
arguments | [in] Unvalidated arguments that separated by space.
Example: "JOIN #channel1,#channel2 key1 key2 :h ello!@:world"
arguments[0] = "#channel1,#channel2"
arguments[1] = "key1"
arguments[2] = "key2"
arguments[3] = "h ello!@:world"
|
- Returns
- The error code of the command execution.
- See also
- Server/ClientCommand/<COMMAND>.cpp
◆ executeClientCommand_NICK()
- Parameters
-
client | [in] The client to process the command. |
arguments | [in] Unvalidated arguments that separated by space.
Example: "JOIN #channel1,#channel2 key1 key2 :h ello!@:world"
arguments[0] = "#channel1,#channel2"
arguments[1] = "key1"
arguments[2] = "key2"
arguments[3] = "h ello!@:world"
|
- Returns
- The error code of the command execution.
- See also
- Server/ClientCommand/<COMMAND>.cpp
◆ executeClientCommand_USER()
- Parameters
-
client | [in] The client to process the command. |
arguments | [in] Unvalidated arguments that separated by space.
Example: "JOIN #channel1,#channel2 key1 key2 :h ello!@:world"
arguments[0] = "#channel1,#channel2"
arguments[1] = "key1"
arguments[2] = "key2"
arguments[3] = "h ello!@:world"
|
- Returns
- The error code of the command execution.
- See also
- Server/ClientCommand/<COMMAND>.cpp
◆ executeClientCommand_JOIN()
- Parameters
-
client | [in] The client to process the command. |
arguments | [in] Unvalidated arguments that separated by space.
Example: "JOIN #channel1,#channel2 key1 key2 :h ello!@:world"
arguments[0] = "#channel1,#channel2"
arguments[1] = "key1"
arguments[2] = "key2"
arguments[3] = "h ello!@:world"
|
- Returns
- The error code of the command execution.
- See also
- Server/ClientCommand/<COMMAND>.cpp
◆ executeClientCommand_MODE()
- Parameters
-
client | [in] The client to process the command. |
arguments | [in] Unvalidated arguments that separated by space.
Example: "JOIN #channel1,#channel2 key1 key2 :h ello!@:world"
arguments[0] = "#channel1,#channel2"
arguments[1] = "key1"
arguments[2] = "key2"
arguments[3] = "h ello!@:world"
|
- Returns
- The error code of the command execution.
- See also
- Server/ClientCommand/<COMMAND>.cpp
◆ executeClientCommand_PRIVMSG()
- Parameters
-
client | [in] The client to process the command. |
arguments | [in] Unvalidated arguments that separated by space.
Example: "JOIN #channel1,#channel2 key1 key2 :h ello!@:world"
arguments[0] = "#channel1,#channel2"
arguments[1] = "key1"
arguments[2] = "key2"
arguments[3] = "h ello!@:world"
|
- Returns
- The error code of the command execution.
- See also
- Server/ClientCommand/<COMMAND>.cpp
◆ executeClientCommand_TOPIC()
- Parameters
-
client | [in] The client to process the command. |
arguments | [in] Unvalidated arguments that separated by space.
Example: "JOIN #channel1,#channel2 key1 key2 :h ello!@:world"
arguments[0] = "#channel1,#channel2"
arguments[1] = "key1"
arguments[2] = "key2"
arguments[3] = "h ello!@:world"
|
- Returns
- The error code of the command execution.
- See also
- Server/ClientCommand/<COMMAND>.cpp
◆ executeClientCommand_KICK()
- Parameters
-
client | [in] The client to process the command. |
arguments | [in] Unvalidated arguments that separated by space.
Example: "JOIN #channel1,#channel2 key1 key2 :h ello!@:world"
arguments[0] = "#channel1,#channel2"
arguments[1] = "key1"
arguments[2] = "key2"
arguments[3] = "h ello!@:world"
|
- Returns
- The error code of the command execution.
- See also
- Server/ClientCommand/<COMMAND>.cpp
◆ executeClientCommand_INVITE()
- Parameters
-
client | [in] The client to process the command. |
arguments | [in] Unvalidated arguments that separated by space.
Example: "JOIN #channel1,#channel2 key1 key2 :h ello!@:world"
arguments[0] = "#channel1,#channel2"
arguments[1] = "key1"
arguments[2] = "key2"
arguments[3] = "h ello!@:world"
|
- Returns
- The error code of the command execution.
- See also
- Server/ClientCommand/<COMMAND>.cpp
◆ executeClientCommand_QUIT()
- Parameters
-
client | [in] The client to process the command. |
arguments | [in] Unvalidated arguments that separated by space.
Example: "JOIN #channel1,#channel2 key1 key2 :h ello!@:world"
arguments[0] = "#channel1,#channel2"
arguments[1] = "key1"
arguments[2] = "key2"
arguments[3] = "h ello!@:world"
|
- Returns
- The error code of the command execution.
- See also
- Server/ClientCommand/<COMMAND>.cpp
◆ executeClientCommand_PART()
- Parameters
-
client | [in] The client to process the command. |
arguments | [in] Unvalidated arguments that separated by space.
Example: "JOIN #channel1,#channel2 key1 key2 :h ello!@:world"
arguments[0] = "#channel1,#channel2"
arguments[1] = "key1"
arguments[2] = "key2"
arguments[3] = "h ello!@:world"
|
- Returns
- The error code of the command execution.
- See also
- Server/ClientCommand/<COMMAND>.cpp
◆ forceDisconnectClient()
Close the client socket and release the client.
◆ disconnectClient()
Mark the client's bExpired flag and block the messages from the client, then close the socket after remaining messages are sent.
Sending to the client is not able after calling this function.
◆ registerClient()
Register a client to the server.
Reply the result of the registration.
- Parameters
-
client | The client to register. |
- Returns
- Result of the registration.
◆ joinClientToChannel()
Join a client to the exist channel without any error/permission check.
◆ partClientFromChannel()
Part a client from the channel without any error/permission check.
◆ findClientGlobal()
◆ findChannelGlobal()
◆ sendMsgToClient()
Send a message to client.
- Parameters
-
client | The client to send the message. |
msg | The message to send. It can contain CR-LF or not. |
◆ sendMsgToChannel()
Send a message to channel members.
- Parameters
-
channel | The channel to send the message. |
msg | The message to send. It can contain CR-LF or not. |
client | A client to exclude from the message sending. |
◆ sendMsgToConnectedChannels()
Send a message to channels the client is connected.
- Parameters
-
client | The client to send the message. This client is excluded from the message sending. |
msg | The message to send. It can contain CR-LF or not. |
◆ logErrorCode()
◆ logMessage()
void IRC::Server::logMessage |
( |
const std::string & | message | ) |
const |
|
private |
◆ logVerbose()
void IRC::Server::logVerbose |
( |
const std::string & | message | ) |
const |
|
private |
◆ mServerName
std::string IRC::Server::mServerName |
|
private |
◆ mServerPort
short IRC::Server::mServerPort |
|
private |
◆ mServerPassword
std::string IRC::Server::mServerPassword |
|
private |
◆ mhListenSocket
int IRC::Server::mhListenSocket |
|
private |
◆ mhKqueue
int IRC::Server::mhKqueue |
|
private |
◆ mEventRegistrationQueue
std::vector<kevent_t> IRC::Server::mEventRegistrationQueue |
|
private |
◆ mUnregistedClients
◆ mClients
◆ mClientReleaseQueue
Queue to release expired clients.
- See also
- ClientDisconnection section in IRC::Server class
◆ mChannels
Channel name to channel map.
- Warning
Caution for using WeakPtr
[한국어]
WeakPtr이 Expired 되어도 map에서 자동으로 제거되지 않습니다.
map을 직접 조작하는 경우 다음과 같은 문제를 주의해야 합니다.
만약 expired 된 엔트리가 제거되지 않은 상태에서 동일한 key로 map::insert() 를 시도하면 덮어씌워지지 않습니다. (map::insert()는 동일한 key가 있을 경우 실패합니다.)
이러한 경우를 방지하기 위해 expired 된 엔트리를 수동으로 제거하거나, map::insert() 대신 map::operator[] 를 사용해야합니다. (operator[]는 동일한 key가 있을 경우 덮어씌웁니다.)
그러므로 가능한 joinClientToChannel(), partClientFromChannel() 등 미리 구현된 함수를 사용해야합니다.
[English]
Even if WeakPtr is Expired, it is not automatically removed from the map.
When directly manipulating the map, you should be aware of the following issues.
If an expired entry is not removed and an attempt is made to map::insert() with the same key, it will not be overwritten. (map::insert() fails if the same key exists.)
To prevent this, you must manually remove the expired entry or use map::operator[] instead of map::insert(). (operator[] overwrites if the same key exists.)
Thus, you should use pre-implemented functions such as joinClientToChannel(), partClientFromChannel().
The documentation for this class was generated from the following files: