IRC_SERVER
By @hyunjunk (hyunjun2372@gmail.com)
Loading...
Searching...
No Matches
ClientControlBlock.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <string>
4#include <vector>
5#include <ctime>
6#include <queue>
7#include <map>
8
10using namespace IRCCore;
11
13#include "Server/MsgBlock.hpp"
14
16
17namespace IRC
18{
19
20/** Control block for management of a client connection and its information.
21 *
22 * @details new/delete overrided with memory pool.
23 */
24class ClientControlBlock : public FlexibleMemoryPoolingBase<ClientControlBlock>
25{
26public:
28
30
31 std::string Nickname;
32 std::string Realname;
33 std::string Username;
34
35 std::string ServerPass;
36
38
40
41 /** Flag that indicate whether the client is expired, and expired client will be released after the remaining messages are sent. */
43
45
46 /** Received messages from the client.
47 *
48 * @details Each message block is not a separate message.
49 * It can be a part of a message or a multiple messages.
50 */
51 std::vector< SharedPtr< MsgBlock > > RecvMsgBlocks;
52
53 /** A cursor to indicate the next offset to receive in the message block at the front of the RecvMsgBlocks */
55
56 /** Queue of messages to send.
57 *
58 * @note Do not modify the message block in the queue.
59 **/
60 std::queue< SharedPtr< MsgBlock > > MsgSendingQueue;
61
62 /** A cursor to indicate the next offset to send in the message block at the front of the MsgSendingQueue */
64
65 /** Map of channel name to the channel control block that the client is connected. */
66 std::map< std::string, SharedPtr< ChannelControlBlock > > Channels;
67
69 : hSocket(-1)
70 , Addr()
71 , Nickname()
72 , Realname()
73 , Username()
74 , ServerPass()
76 , bRegistered(false)
77 , bExpired(false)
78 , bSocketClosed(false)
83 , Channels()
84 {
85 }
86
88 {
89 std::map< std::string, SharedPtr< ChannelControlBlock > >::iterator it = Channels.find(ChannelName);
90 if (it != Channels.end())
91 {
92 return it->second;
93 }
95 }
96};
97} // namespace IRC
#define FORCEINLINE
Definition AttributeDefines.hpp:55
struct sockaddr_in sockaddr_in_t
Definition SocketTypedef.hpp:11
Control block for management of a client connection and its information.
Definition ClientControlBlock.hpp:25
std::string Realname
Definition ClientControlBlock.hpp:32
std::vector< SharedPtr< MsgBlock > > RecvMsgBlocks
Received messages from the client.
Definition ClientControlBlock.hpp:51
int hSocket
Definition ClientControlBlock.hpp:27
std::string Username
Definition ClientControlBlock.hpp:33
SharedPtr< ChannelControlBlock > FindChannel(const std::string &ChannelName)
Definition ClientControlBlock.hpp:87
ClientControlBlock()
Definition ClientControlBlock.hpp:68
std::queue< SharedPtr< MsgBlock > > MsgSendingQueue
Queue of messages to send.
Definition ClientControlBlock.hpp:60
size_t RecvMsgBlockCursor
A cursor to indicate the next offset to receive in the message block at the front of the RecvMsgBlock...
Definition ClientControlBlock.hpp:54
std::string Nickname
Definition ClientControlBlock.hpp:31
bool bSocketClosed
Definition ClientControlBlock.hpp:44
std::string ServerPass
Definition ClientControlBlock.hpp:35
std::map< std::string, SharedPtr< ChannelControlBlock > > Channels
Map of channel name to the channel control block that the client is connected.
Definition ClientControlBlock.hpp:66
size_t SendMsgBlockCursor
A cursor to indicate the next offset to send in the message block at the front of the MsgSendingQueue...
Definition ClientControlBlock.hpp:63
time_t LastActiveTime
Definition ClientControlBlock.hpp:37
bool bRegistered
Definition ClientControlBlock.hpp:39
sockaddr_in_t Addr
Definition ClientControlBlock.hpp:29
bool bExpired
Flag that indicate whether the client is expired, and expired client will be released after the remai...
Definition ClientControlBlock.hpp:42
Base class for memory pooling with new/delete operator overloading.
Definition FlexibleMemoryPoolingBase.hpp:39
Shared pointer custom implementation for C++98 standard.
Definition SharedPtr.hpp:164
Definition ControlBlock.hpp:7
Definition ChannelControlBlock.hpp:12