ft_irc 1.0
読み取り中…
検索中…
一致する文字列を見つけられません
Client クラス

Represents an IRC client connected to the server. [詳解]

#include <Client.hpp>

Client 連携図
Collaboration graph

公開メンバ関数

 Client (int fd, const std::string &hostname)
 Constructs a new Client object.
 
virtual ~Client ()
 Destroys the Client object.
 
int getFd () const
 Gets the client's file descriptor.
 
const std::stringgetNickname () const
 Gets the client's nickname.
 
const std::stringgetUsername () const
 Gets the client's username.
 
const std::stringgetHostname () const
 Gets the client's hostname.
 
bool isAuthenticated () const
 Checks if the client is authenticated.
 
bool isRegistered () const
 Checks if the client is registered.
 
std::string getPrefix () const
 Generates the client's IRC prefix (e.g., :nick!user@host).
 
bool isMarkedForDisconnect () const
 Checks if the client is marked for disconnection.
 
const std::stringgetQuitMessage () const
 Gets the client's quit message.
 
const std::stringgetRealname () const
 Gets the client's real name.
 
const std::stringgetSendBuffer () const
 Gets the client's send buffer content.
 
const std::vector< Channel * > & getChannels () const
 Gets the list of channels the client is in.
 
std::time_t getLastActivityTime () const
 Gets the timestamp of the client's last activity.
 
std::time_t getLastPingSentTime () const
 Gets the timestamp of the last PING sent to the client.
 
void setNickname (const std::string &nickname)
 Sets the client's nickname.
 
void setUsername (const std::string &username)
 Sets the client's username.
 
void setRealname (const std::string &realname)
 Sets the client's real name.
 
void setAuthenticated (bool value)
 Sets the client's authentication status.
 
void setRegistered (bool value)
 Sets the client's registration status.
 
void markForDisconnect (const std::string &message)
 Marks the client for disconnection with a specified message.
 
void addChannel (Channel *channel)
 Adds a channel to the client's list of joined channels.
 
void removeChannel (Channel *channel)
 Removes a channel from the client's list of joined channels.
 
void updateActivityTime ()
 Updates the client's last activity time to the current time.
 
void setLastPingSentTime (std::time_t time)
 Sets the timestamp of the last PING sent to the client.
 
void clearPingSentTime ()
 Clears the last PING sent time, indicating no PING is currently pending a PONG. This should be called when a valid PONG response is received from the client.
 
void appendBuffer (const std::string &data)
 Appends data to the client's receive buffer.
 
void appendToSendBuffer (const std::string &data)
 Appends data to the client's send buffer.
 
std::string readLineFromBuffer ()
 Reads a single line from the receive buffer.
 
void removeSentData (size_t bytes_sent)
 Removes a specified number of bytes from the beginning of the send buffer.
 
virtual void sendMessage (const std::string &message) const
 Sends a message to the client by appending it to the send buffer.
 

静的公開変数類

static const size_t MAX_SENDBUFF_SIZE = 1024 * 1024
 Maximum size of the send buffer (1MB).
 

限定公開変数類

std::time_t _lastActivityTime
 Timestamp of the last activity from the client.
 
std::time_t _lastPingSentTime
 Timestamp of the last PING sent to the client.
 

詳解

Represents an IRC client connected to the server.

This class manages the state and attributes of a single IRC client, including its file descriptor, nickname, username, hostname, authentication and registration status, and communication buffers. It also tracks the client's activity and ping times.

各種例
join_and_msg.cpp.

Client.hpp25 行目に定義があります。

構築子と解体子

◆ Client()

Client::Client ( int  fd,
const std::string hostname 
)

Constructs a new Client object.

引数
fdThe client's file descriptor.
hostnameThe client's hostname.

Client.cpp15 行目に定義があります。

◆ ~Client()

Client::~Client ( )
virtual

Destroys the Client object.

Client.cpp20 行目に定義があります。

関数詳解

◆ addChannel()

void Client::addChannel ( Channel channel)

Adds a channel to the client's list of joined channels.

引数
channelA pointer to the Channel object.

Client.cpp73 行目に定義があります。

◆ appendBuffer()

void Client::appendBuffer ( const std::string data)

Appends data to the client's receive buffer.

引数
dataThe data to append.

Client.cpp94 行目に定義があります。

◆ appendToSendBuffer()

void Client::appendToSendBuffer ( const std::string data)

Appends data to the client's send buffer.

引数
dataThe data to append.

Client.cpp97 行目に定義があります。

◆ clearPingSentTime()

void Client::clearPingSentTime ( )

Clears the last PING sent time, indicating no PING is currently pending a PONG. This should be called when a valid PONG response is received from the client.

Client.cpp91 行目に定義があります。

◆ getChannels()

const std::vector< Channel * > & Client::getChannels ( ) const

Gets the list of channels the client is in.

戻り値
A vector of Channel pointers.

Client.cpp43 行目に定義があります。

◆ getFd()

int Client::getFd ( ) const

Gets the client's file descriptor.

戻り値
The file descriptor.

Client.cpp23 行目に定義があります。

◆ getHostname()

const std::string & Client::getHostname ( ) const

Gets the client's hostname.

戻り値
The hostname.

Client.cpp29 行目に定義があります。

◆ getLastActivityTime()

time_t Client::getLastActivityTime ( ) const

Gets the timestamp of the client's last activity.

戻り値
The last activity time.

Client.cpp45 行目に定義があります。

◆ getLastPingSentTime()

time_t Client::getLastPingSentTime ( ) const

Gets the timestamp of the last PING sent to the client.

戻り値
The last PING sent time.

Client.cpp47 行目に定義があります。

◆ getNickname()

const std::string & Client::getNickname ( ) const

Gets the client's nickname.

戻り値
The nickname.

Client.cpp25 行目に定義があります。

◆ getPrefix()

std::string Client::getPrefix ( ) const

Generates the client's IRC prefix (e.g., :nick!user@host).

戻り値
The client's prefix.

Client.cpp50 行目に定義があります。

◆ getQuitMessage()

const std::string & Client::getQuitMessage ( ) const

Gets the client's quit message.

戻り値
The quit message.

Client.cpp37 行目に定義があります。

◆ getRealname()

const std::string & Client::getRealname ( ) const

Gets the client's real name.

戻り値
The real name.

Client.cpp39 行目に定義があります。

◆ getSendBuffer()

const std::string & Client::getSendBuffer ( ) const

Gets the client's send buffer content.

戻り値
The send buffer content.

Client.cpp41 行目に定義があります。

◆ getUsername()

const std::string & Client::getUsername ( ) const

Gets the client's username.

戻り値
The username.

Client.cpp27 行目に定義があります。

◆ isAuthenticated()

bool Client::isAuthenticated ( ) const

Checks if the client is authenticated.

戻り値
True if authenticated, false otherwise.

Client.cpp31 行目に定義があります。

◆ isMarkedForDisconnect()

bool Client::isMarkedForDisconnect ( ) const

Checks if the client is marked for disconnection.

戻り値
True if marked for disconnection, false otherwise.

Client.cpp35 行目に定義があります。

◆ isRegistered()

bool Client::isRegistered ( ) const

Checks if the client is registered.

戻り値
True if registered, false otherwise.

Client.cpp33 行目に定義があります。

◆ markForDisconnect()

void Client::markForDisconnect ( const std::string message)

Marks the client for disconnection with a specified message.

引数
messageThe quit message.

Client.cpp68 行目に定義があります。

◆ readLineFromBuffer()

std::string Client::readLineFromBuffer ( )

Reads a single line from the receive buffer.

戻り値
The extracted line, or an empty string if no complete line is available.

Client.cpp118 行目に定義があります。

◆ removeChannel()

void Client::removeChannel ( Channel channel)

Removes a channel from the client's list of joined channels.

引数
channelA pointer to the Channel object.

Client.cpp83 行目に定義があります。

◆ removeSentData()

void Client::removeSentData ( size_t  bytes_sent)

Removes a specified number of bytes from the beginning of the send buffer.

引数
bytes_sentThe number of bytes to remove.

Client.cpp109 行目に定義があります。

◆ sendMessage()

void Client::sendMessage ( const std::string message) const
virtual

Sends a message to the client by appending it to the send buffer.

引数
messageThe message to send.

Client.cpp135 行目に定義があります。

◆ setAuthenticated()

void Client::setAuthenticated ( bool  value)

Sets the client's authentication status.

引数
valueTrue for authenticated, false otherwise.

Client.cpp64 行目に定義があります。

◆ setLastPingSentTime()

void Client::setLastPingSentTime ( std::time_t  time)

Sets the timestamp of the last PING sent to the client.

引数
timeThe new timestamp.

Client.cpp89 行目に定義があります。

◆ setNickname()

void Client::setNickname ( const std::string nickname)

Sets the client's nickname.

引数
nicknameThe new nickname.
各種例
join_and_msg.cpp.

Client.cpp58 行目に定義があります。

◆ setRealname()

void Client::setRealname ( const std::string realname)

Sets the client's real name.

引数
realnameThe new real name.

Client.cpp62 行目に定義があります。

◆ setRegistered()

void Client::setRegistered ( bool  value)

Sets the client's registration status.

引数
valueTrue for registered, false otherwise.

Client.cpp66 行目に定義があります。

◆ setUsername()

void Client::setUsername ( const std::string username)

Sets the client's username.

引数
usernameThe new username.

Client.cpp60 行目に定義があります。

◆ updateActivityTime()

void Client::updateActivityTime ( )

Updates the client's last activity time to the current time.

Client.cpp87 行目に定義があります。

メンバ詳解

◆ _lastActivityTime

std::time_t Client::_lastActivityTime
protected

Timestamp of the last activity from the client.

Client.hpp43 行目に定義があります。

◆ _lastPingSentTime

std::time_t Client::_lastPingSentTime
protected

Timestamp of the last PING sent to the client.

Client.hpp44 行目に定義があります。

◆ MAX_SENDBUFF_SIZE

const size_t Client::MAX_SENDBUFF_SIZE = 1024 * 1024
static

Maximum size of the send buffer (1MB).

Client.hpp27 行目に定義があります。


このクラス詳解は次のファイルから抽出されました: