Minetest  5.4.0
ClientInterface Class Reference

#include <clientiface.h>

+ Collaboration diagram for ClientInterface:

Public Member Functions

 ClientInterface (const std::shared_ptr< con::Connection > &con)
 
 ~ClientInterface ()
 
void step (float dtime)
 
std::vector< session_tgetClientIDs (ClientState min_state=CS_Active)
 
void markBlockposAsNotSent (const v3s16 &pos)
 
bool isUserLimitReached ()
 Verify if user limit was reached. More...
 
const std::vector< std::string > & getPlayerNames () const
 
void send (session_t peer_id, u8 channelnum, NetworkPacket *pkt, bool reliable)
 
void sendToAll (NetworkPacket *pkt)
 
void sendToAllCompat (NetworkPacket *pkt, NetworkPacket *legacypkt, u16 min_proto_ver)
 
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

void lock ()
 
void unlock ()
 
RemoteClientMapgetClientList ()
 

Private Member Functions

void UpdatePlayerList ()
 

Private Attributes

std::shared_ptr< con::Connectionm_con
 
std::recursive_mutex m_clients_mutex
 
RemoteClientMap m_clients
 
std::vector< std::string > m_clients_names
 
ServerEnvironmentm_env
 
float m_print_info_timer
 

Static Private Attributes

static const char * statenames []
 

Friends

class Server
 

Constructor & Destructor Documentation

◆ ClientInterface()

ClientInterface::ClientInterface ( const std::shared_ptr< con::Connection > &  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::handlePeerChanges().

+ 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, m_clients, m_clients_mutex, and UpdatePlayerList().

Referenced by Server::acceptAuth(), Server::deletingPeer(), Server::DenyAccess(), Server::DenyAccess_Legacy(), Server::DenyAccessVerCompliant(), 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::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::fadeSound(), Server::handleCommand_Init2(), 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:

◆ lock()

void ClientInterface::lock ( )
inlineprotected

References m_clients_mutex.

Referenced by Server::AsyncRunStep(), Server::dynamicAddMedia(), Server::getClientInfo(), Server::handleCommand_GotBlocks(), Server::sendAddNode(), Server::SendBlock(), Server::SendBlocks(), Server::sendMetadataChanged(), Server::sendRemoveNode(), Server::SetBlocksNotSent(), and Server::StageTwoClientInit().

+ 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::getClientInfo(), Server::handleCommand_GotBlocks(), Server::sendAddNode(), Server::SendBlock(), Server::SendBlocks(), Server::sendMetadataChanged(), Server::sendRemoveNode(), Server::SetBlocksNotSent(), Server::StageTwoClientInit(), and UpdatePlayerList().

+ Here is the caller graph for this function:

◆ markBlockposAsNotSent()

void ClientInterface::markBlockposAsNotSent ( const v3s16 pos)

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,
u8  channelnum,
NetworkPacket pkt,
bool  reliable 
)

References m_con.

Referenced by Server::dynamicAddMedia(), Server::fadeSound(), Server::handleCommand_ClientReady(), Server::playSound(), Server::Send(), Server::SendActiveObjectMessages(), Server::sendAddNode(), Server::sendMetadataChanged(), Server::sendRemoveNode(), and Server::stopSound().

+ Here is the caller graph for this function:

◆ sendToAll()

void ClientInterface::sendToAll ( NetworkPacket pkt)

References ClientCommandFactory::channel, clientCommandFactoryTable, NetworkPacket::getCommand(), m_clients, m_clients_mutex, m_con, and ClientCommandFactory::reliable.

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

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

◆ sendToAllCompat()

void ClientInterface::sendToAllCompat ( NetworkPacket pkt,
NetworkPacket legacypkt,
u16  min_proto_ver 
)

References ClientCommandFactory::channel, clientCommandFactoryTable, NetworkPacket::getCommand(), m_clients, m_clients_mutex, m_con, ClientCommandFactory::reliable, and warningstream.

+ Here is the call 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().

+ Here is the caller graph for this function:

◆ step()

void ClientInterface::step ( float  dtime)

References m_print_info_timer, and UpdatePlayerList().

Referenced by Server::AsyncRunStep().

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

◆ unlock()

void ClientInterface::unlock ( )
inlineprotected

References m_clients_mutex.

Referenced by Server::AsyncRunStep(), Server::dynamicAddMedia(), Server::getClientInfo(), Server::handleCommand_GotBlocks(), Server::sendAddNode(), Server::SendBlock(), Server::SendBlocks(), Server::sendMetadataChanged(), Server::sendRemoveNode(), Server::SetBlocksNotSent(), and Server::StageTwoClientInit().

+ 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 Function Documentation

◆ Server

friend class Server
friend

Member Data Documentation

◆ 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::Connection> ClientInterface::m_con
private

Referenced by send(), sendToAll(), and sendToAllCompat().

◆ m_env

ServerEnvironment* ClientInterface::m_env
private

◆ m_print_info_timer

float ClientInterface::m_print_info_timer
private

Referenced by step().

◆ statenames

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

Referenced by state2Name().


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