10#include <sys/socket.h>
125 Server(
const std::string& serverName,
const unsigned short port,
const std::string& password);
184#define IRC_CLIENT_COMMAND_X(command_name) IRC::EIrcErrorCode executeClientCommand_##command_name(SharedPtr<ClientControlBlock> client, const std::vector<char*>& arguments);
198#undef IRC_CLIENT_COMMAND_X
271 void logMessage(
const std::string& message)
const;
273 void logVerbose(
const std::string& message)
const;
323 std::map< std::string, SharedPtr< ClientControlBlock > >
mClients;
350 std::map< std::string, WeakPtr< ChannelControlBlock > >
mChannels;
#define FORCEINLINE
Definition AttributeDefines.hpp:55
#define UNUSED
Definition AttributeDefines.hpp:30
#define IRC_CLIENT_COMMAND_LIST
Definition ClientCommand.hpp:12
struct kevent kevent_t
Definition SocketTypedef.hpp:9
Definition Server.hpp:101
EIrcErrorCode separateMsgsFromClientRecvMsgs(SharedPtr< ClientControlBlock > client, std::vector< SharedPtr< MsgBlock > > &outSeparatedMsgs)
Separate all separable messages in the client's ClientControlBlock::RecvMsgBlocks.
Definition Server.cpp:485
EIrcErrorCode eventLoop()
A main event loop of the server.
Definition Server.cpp:119
std::vector< kevent_t > mEventRegistrationQueue
Definition Server.hpp:312
EIrcErrorCode Startup()
Initialize resources and start the server event loop.
Definition Server.cpp:54
void logMessage(const std::string &message) const
Definition Server.cpp:1012
std::map< std::string, SharedPtr< ClientControlBlock > > mClients
Nickname to client map.
Definition Server.hpp:323
EIrcErrorCode disconnectClient(SharedPtr< ClientControlBlock > client, const std::string quitMessage="")
Mark the client's bExpired flag and block the messages from the client, then close the socket after r...
Definition Server.cpp:791
SharedPtr< ClientControlBlock > findClientGlobal(const std::string &nickname)
Definition Server.cpp:896
EIrcErrorCode processClientMsg(SharedPtr< ClientControlBlock > client, SharedPtr< MsgBlock > msg)
Execute and reply the client's single message.
Definition Server.cpp:582
bool registerClient(SharedPtr< ClientControlBlock > client)
Register a client to the server.
Definition Server.cpp:836
void logErrorCode(EIrcErrorCode errorCode) const
Definition Server.cpp:1007
void sendMsgToChannel(SharedPtr< ChannelControlBlock > channel, SharedPtr< MsgBlock > msg, SharedPtr< ClientControlBlock > exceptClient=NULL)
Send a message to channel members.
Definition Server.cpp:973
UNUSED Server & operator=(const Server &rhs)
Definition Server.cpp:15
std::vector< SharedPtr< ClientControlBlock > > mUnregistedClients
Nickname to client map.
Definition Server.hpp:320
std::string mServerPassword
Definition Server.hpp:279
void joinClientToChannel(SharedPtr< ClientControlBlock > client, SharedPtr< ChannelControlBlock > channel)
Join a client to the exist channel without any error/permission check.
Definition Server.cpp:883
static EIrcErrorCode CreateServer(Server **outPtrServer, const std::string &serverName, const unsigned short port, const std::string &password)
Create a server instance.
Definition Server.cpp:21
void partClientFromChannel(SharedPtr< ClientControlBlock > client, SharedPtr< ChannelControlBlock > channel)
Part a client from the channel without any error/permission check.
Definition Server.cpp:889
IRC::EIrcErrorCode(Server::*) ClientCommandFuncPtr(SharedPtr< ClientControlBlock > client, const std::vector< char * > &arguments)
Client command execution function type.
Definition Server.hpp:174
EIrcErrorCode destroyResources()
Destroy all resources of the server.
Definition Server.cpp:439
void logVerbose(const std::string &message) const
Definition Server.cpp:1017
SharedPtr< ClientControlBlock > getClientFromKeventUdata(kevent_t &event) const
Get SharedPtr to the ClientControlBlock from the kevent's udata.
Definition Server.hpp:164
Server(const std::string &serverName, const unsigned short port, const std::string &password)
Definition Server.cpp:44
short mServerPort
Definition Server.hpp:278
int mhKqueue
Definition Server.hpp:311
int mhListenSocket
Definition Server.hpp:281
void sendMsgToClient(SharedPtr< ClientControlBlock > client, SharedPtr< MsgBlock > msg)
Send a message to client.
Definition Server.cpp:929
std::vector< SharedPtr< ClientControlBlock > > mClientReleaseQueue
Queue to release expired clients.
Definition Server.hpp:330
~Server()
Definition Server.cpp:10
SharedPtr< ChannelControlBlock > findChannelGlobal(const std::string &channelName)
Definition Server.cpp:912
void sendMsgToConnectedChannels(SharedPtr< ClientControlBlock > client, SharedPtr< MsgBlock > msg)
Send a message to channels the client is connected.
Definition Server.cpp:990
std::map< std::string, WeakPtr< ChannelControlBlock > > mChannels
Channel name to channel map.
Definition Server.hpp:350
EIrcErrorCode forceDisconnectClient(SharedPtr< ClientControlBlock > client, const std::string quitMessage="")
Close the client socket and release the client.
Definition Server.cpp:713
std::string mServerName
Definition Server.hpp:277
Shared pointer custom implementation for C++98 standard.
Definition SharedPtr.hpp:164
Definition ControlBlock.hpp:7
Definition ChannelControlBlock.hpp:12
EIrcErrorCode
Error Codes Enum.
Definition IrcErrorCode.hpp:49
Do not use this class directly.
Definition SharedPtr.hpp:31