Luanti 5.10.0-dev
 
Loading...
Searching...
No Matches
ClientInterface Class Reference

#include <clientiface.h>

+ Collaboration diagram for ClientInterface:

Classes

class  AutoLock
 

Public Member Functions

 ClientInterface (const std::shared_ptr< con::IConnection > &con)
 
 ~ClientInterface ()
 
void step (float dtime)
 
std::vector< session_tgetClientIDs (ClientState min_state=CS_Active)
 
void markBlocksNotSent (const std::vector< v3s16 > &positions)
 
bool isUserLimitReached ()
 Verify if user limit was reached.
 
const std::vector< std::string > & getPlayerNames () const
 
void send (session_t peer_id, NetworkPacket *pkt)
 
void sendCustom (session_t peer_id, u8 channel, NetworkPacket *pkt, bool reliable)
 
void sendToAll (NetworkPacket *pkt)
 
void DeleteClient (session_t peer_id)
 
void CreateClient (session_t peer_id)
 
RemoteClientgetClientNoEx (session_t peer_id, ClientState state_min=CS_Active)
 
RemoteClientlockedGetClientNoEx (session_t peer_id, ClientState state_min=CS_Active)
 
ClientState getClientState (session_t peer_id)
 
void setPlayerName (session_t peer_id, const std::string &name)
 
u16 getProtocolVersion (session_t peer_id)
 
void setClientVersion (session_t peer_id, u8 major, u8 minor, u8 patch, const std::string &full)
 
void event (session_t peer_id, ClientStateEvent event)
 
void setEnv (ServerEnvironment *env)
 

Static Public Member Functions

static std::string state2Name (ClientState state)
 

Protected Member Functions

RemoteClientMapgetClientList ()
 

Private Member Functions

void UpdatePlayerList ()
 

Private Attributes

std::shared_ptr< con::IConnectionm_con
 
std::recursive_mutex m_clients_mutex
 
RemoteClientMap m_clients
 
std::vector< std::string > m_clients_names
 
ServerEnvironmentm_env
 
float m_print_info_timer = 0
 
float m_check_linger_timer = 0
 

Static Private Attributes

static const char * statenames []
 
static constexpr int LINGER_TIMEOUT = 10
 

Friends

class Server
 

Constructor & Destructor Documentation

◆ ClientInterface()

ClientInterface::ClientInterface ( const std::shared_ptr< con::IConnection > & con)

◆ ~ClientInterface()

ClientInterface::~ClientInterface ( )

References m_clients, and m_clients_mutex.

Member Function Documentation

◆ CreateClient()

void ClientInterface::CreateClient ( session_t peer_id)

References m_clients, and m_clients_mutex.

Referenced by Server::peerAdded().

+ Here is the caller graph for this function:

◆ DeleteClient()

void ClientInterface::DeleteClient ( session_t peer_id)

References ServerEnvironment::getActiveObject(), m_clients, m_clients_mutex, m_env, and ServerActiveObject::m_known_by_count.

Referenced by Server::DeleteClient().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ event()

void ClientInterface::event ( session_t peer_id,
ClientStateEvent event )

References CSE_Disconnect, CSE_SetClientReady, CSE_SetDenied, event(), m_clients, m_clients_mutex, and UpdatePlayerList().

Referenced by Server::acceptAuth(), Server::deletingPeer(), Server::DenyAccess(), event(), Server::handleCommand_ClientReady(), Server::handleCommand_FirstSrp(), Server::handleCommand_Init(), and Server::handleCommand_Init2().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getClientIDs()

std::vector< session_t > ClientInterface::getClientIDs ( ClientState min_state = CS_Active)

◆ getClientList()

RemoteClientMap & ClientInterface::getClientList ( )
inlineprotected

References m_clients.

Referenced by Server::AsyncRunStep(), and Server::dynamicAddMedia().

+ Here is the caller graph for this function:

◆ getClientNoEx()

RemoteClient * ClientInterface::getClientNoEx ( session_t peer_id,
ClientState state_min = CS_Active )

References m_clients, and m_clients_mutex.

Referenced by Server::getClientNoEx().

+ Here is the caller graph for this function:

◆ getClientState()

ClientState ClientInterface::getClientState ( session_t peer_id)

References CS_Invalid, m_clients, and m_clients_mutex.

Referenced by Server::ProcessData().

+ Here is the caller graph for this function:

◆ getPlayerNames()

const std::vector< std::string > & ClientInterface::getPlayerNames ( ) const
inline

References m_clients_names.

Referenced by Server::AsyncRunStep(), Server::getStatusString(), Server::handleCommand_ClientReady(), and Server::StageTwoClientInit().

+ Here is the caller graph for this function:

◆ getProtocolVersion()

u16 ClientInterface::getProtocolVersion ( session_t peer_id)

References m_clients, and m_clients_mutex.

Referenced by Server::handleCommand_Init2(), Server::SendLocalPlayerAnimations(), and Server::SendSetSky().

+ Here is the caller graph for this function:

◆ isUserLimitReached()

bool ClientInterface::isUserLimitReached ( )

Verify if user limit was reached.

User limit count all clients from HelloSent state (MT protocol user) to Active state

Returns
true if user limit was reached

References CS_HelloSent, g_settings, getClientIDs(), and Settings::getU16().

Referenced by Server::handleCommand_Init().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ lockedGetClientNoEx()

RemoteClient * ClientInterface::lockedGetClientNoEx ( session_t peer_id,
ClientState state_min = CS_Active )

References m_clients.

Referenced by Server::getClientDynamicInfo(), Server::getClientInfo(), Server::handleCommand_GotBlocks(), Server::SendBlock(), Server::SendBlocks(), Server::sendMetadataChanged(), Server::sendNodeChangePkt(), Server::StageTwoClientInit(), and UpdatePlayerList().

+ Here is the caller graph for this function:

◆ markBlocksNotSent()

void ClientInterface::markBlocksNotSent ( const std::vector< v3s16 > & positions)

References CS_Active, m_clients, and m_clients_mutex.

Referenced by Server::AsyncRunStep().

+ Here is the caller graph for this function:

◆ send()

void ClientInterface::send ( session_t peer_id,
NetworkPacket * pkt )

References clientCommandFactoryTable, FATAL_ERROR_IF, NetworkPacket::getCommand(), m_con, and con::IConnection::Send().

Referenced by Server::Send().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ sendCustom()

void ClientInterface::sendCustom ( session_t peer_id,
u8 channel,
NetworkPacket * pkt,
bool reliable )

References clientCommandFactoryTable, FATAL_ERROR_IF, NetworkPacket::getCommand(), m_con, ClientCommandFactory::name, and con::IConnection::Send().

Referenced by Server::dynamicAddMedia(), Server::playSound(), and Server::SendActiveObjectMessages().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ sendToAll()

void ClientInterface::sendToAll ( NetworkPacket * pkt)

References clientCommandFactoryTable, FATAL_ERROR_IF, NetworkPacket::getCommand(), m_clients, m_clients_mutex, m_con, and con::IConnection::Send().

Referenced by Server::DeleteClient(), Server::SendChatMessage(), Server::SendDeleteParticleSpawner(), Server::sendDetachedInventory(), Server::SendTimeOfDay(), and Server::StageTwoClientInit().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setClientVersion()

void ClientInterface::setClientVersion ( session_t peer_id,
u8 major,
u8 minor,
u8 patch,
const std::string & full )

References m_clients, and m_clients_mutex.

Referenced by Server::handleCommand_ClientReady().

+ Here is the caller graph for this function:

◆ setEnv()

void ClientInterface::setEnv ( ServerEnvironment * env)
inline

References m_env.

Referenced by Server::init().

+ Here is the caller graph for this function:

◆ setPlayerName()

void ClientInterface::setPlayerName ( session_t peer_id,
const std::string & name )

References m_clients, and m_clients_mutex.

Referenced by Server::handleCommand_Init().

+ Here is the caller graph for this function:

◆ state2Name()

std::string ClientInterface::state2Name ( ClientState state)
static

References statenames.

Referenced by ModApiServer::l_get_player_information(), and step().

+ Here is the caller graph for this function:

◆ step()

void ClientInterface::step ( float dtime)

References CS_Created, CS_HelloSent, CS_Invalid, con::IConnection::DisconnectPeer(), con::IConnection::GetPeerAddress(), infostream, LINGER_TIMEOUT, m_check_linger_timer, m_clients, m_clients_mutex, m_con, m_print_info_timer, Address::serializeString(), state2Name(), UpdatePlayerList(), and warningstream.

Referenced by Server::AsyncRunStep().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ UpdatePlayerList()

void ClientInterface::UpdatePlayerList ( )
private

References getClientIDs(), Player::getName(), ServerEnvironment::getPlayer(), infostream, lockedGetClientNoEx(), m_clients_mutex, m_clients_names, and m_env.

Referenced by event(), and step().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Friends And Related Symbol Documentation

◆ Server

friend class Server
friend

Member Data Documentation

◆ LINGER_TIMEOUT

int ClientInterface::LINGER_TIMEOUT = 10
staticconstexprprivate

Referenced by step().

◆ m_check_linger_timer

float ClientInterface::m_check_linger_timer = 0
private

Referenced by step().

◆ m_clients

◆ m_clients_mutex

◆ m_clients_names

std::vector<std::string> ClientInterface::m_clients_names
private

Referenced by getPlayerNames(), and UpdatePlayerList().

◆ m_con

std::shared_ptr<con::IConnection> ClientInterface::m_con
private

Referenced by send(), sendCustom(), sendToAll(), and step().

◆ m_env

ServerEnvironment* ClientInterface::m_env
private

◆ m_print_info_timer

float ClientInterface::m_print_info_timer = 0
private

Referenced by step().

◆ statenames

const char * ClientInterface::statenames
staticprivate
Initial value:
= {
"Invalid",
"Disconnecting",
"Denied",
"Created",
"HelloSent",
"AwaitingInit2",
"InitDone",
"DefinitionsSent",
"Active",
"SudoMode",
}

Referenced by state2Name().


The documentation for this class was generated from the following files: