Botcraft 1.21.4
Loading...
Searching...
No Matches
Botcraft::ConnectionClient Class Reference

The base client handling connection with a server. More...

#include <ConnectionClient.hpp>

Inheritance diagram for Botcraft::ConnectionClient:
ProtocolCraft::Handler ProtocolCraft::GenericHandler< Message, AllMessages > Botcraft::ManagersClient Botcraft::BehaviourClient Botcraft::TemplatedBehaviourClient< SimpleBehaviourClient > Botcraft::TemplatedBehaviourClient< TDerived > Botcraft::SimpleBehaviourClient

Public Member Functions

 ConnectionClient ()
 
virtual ~ConnectionClient ()
 
void Connect (const std::string &address, const std::string &login, const bool force_microsoft_account=false)
 Connect the client to the server at address.
 
virtual void Disconnect ()
 
bool GetShouldBeClosed () const
 
void SetShouldBeClosed (const bool b)
 
std::shared_ptr< NetworkManagerGetNetworkManager () const
 
void SendChatMessage (const std::string &msg)
 Send a message in the game chat.
 
void SendChatCommand (const std::string &command)
 Send a command in the game chat.
 
void Respawn ()
 Ask to respawn when dead.
 

Protected Member Functions

virtual void Handle (ProtocolCraft::ClientboundLoginDisconnectPacket &msg) override
 
virtual void Handle (ProtocolCraft::ClientboundDisconnectPacket &msg) override
 
virtual void Handle (ProtocolCraft::ClientboundPlayerPositionPacket &msg) override
 
virtual void Handle (ProtocolCraft::ClientboundDisconnectConfigurationPacket &msg) override
 
virtual void Handle (ProtocolCraft::ClientboundLoginPacket &msg) override
 
virtual void Handle (ProtocolCraft::ClientboundRespawnPacket &msg) override
 

Protected Attributes

std::shared_ptr< NetworkManagernetwork_manager
 
bool should_be_closed
 

Detailed Description

The base client handling connection with a server.

Only processes packets required to maintain the connection.

Definition at line 11 of file ConnectionClient.hpp.

Constructor & Destructor Documentation

◆ ConnectionClient()

Botcraft::ConnectionClient::ConnectionClient ( )

Definition at line 9 of file ConnectionClient.cpp.

References network_manager, and should_be_closed.

◆ ~ConnectionClient()

Botcraft::ConnectionClient::~ConnectionClient ( )
virtual

Definition at line 15 of file ConnectionClient.cpp.

References Disconnect().

Member Function Documentation

◆ Connect()

void Botcraft::ConnectionClient::Connect ( const std::string &  address,
const std::string &  login,
const bool  force_microsoft_account = false 
)

Connect the client to the server at address.

Parameters
addressAddress to connect to, as written in minecraft multiplayer window
loginIf login is empty, will try to connect with a Microsoft account
force_microsoft_accountIf true, then Microsoft auth flow will be used. In this case, login is used as key to cache the credentials

Definition at line 20 of file ConnectionClient.cpp.

References network_manager.

◆ Disconnect()

void Botcraft::ConnectionClient::Disconnect ( )
virtual

Reimplemented in Botcraft::ManagersClient.

Definition at line 25 of file ConnectionClient.cpp.

References network_manager, and should_be_closed.

Referenced by Botcraft::ManagersClient::Disconnect(), and ~ConnectionClient().

◆ GetNetworkManager()

◆ GetShouldBeClosed()

bool Botcraft::ConnectionClient::GetShouldBeClosed ( ) const

Definition at line 35 of file ConnectionClient.cpp.

References should_be_closed.

◆ Handle() [1/6]

void Botcraft::ConnectionClient::Handle ( ProtocolCraft::ClientboundDisconnectConfigurationPacket msg)
overrideprotectedvirtual

◆ Handle() [2/6]

void Botcraft::ConnectionClient::Handle ( ProtocolCraft::ClientboundDisconnectPacket msg)
overrideprotectedvirtual

◆ Handle() [3/6]

void Botcraft::ConnectionClient::Handle ( ProtocolCraft::ClientboundLoginDisconnectPacket msg)
overrideprotectedvirtual

◆ Handle() [4/6]

void Botcraft::ConnectionClient::Handle ( ProtocolCraft::ClientboundLoginPacket msg)
overrideprotectedvirtual

Reimplemented in Botcraft::ManagersClient, and Botcraft::ManagersClient.

Definition at line 139 of file ConnectionClient.cpp.

References network_manager.

◆ Handle() [5/6]

void Botcraft::ConnectionClient::Handle ( ProtocolCraft::ClientboundPlayerPositionPacket msg)
overrideprotectedvirtual

Reimplemented in Botcraft::ManagersClient, and Botcraft::ManagersClient.

Definition at line 116 of file ConnectionClient.cpp.

References network_manager.

◆ Handle() [6/6]

void Botcraft::ConnectionClient::Handle ( ProtocolCraft::ClientboundRespawnPacket msg)
overrideprotectedvirtual

Reimplemented in Botcraft::ManagersClient, and Botcraft::ManagersClient.

Definition at line 144 of file ConnectionClient.cpp.

References network_manager.

◆ Respawn()

void Botcraft::ConnectionClient::Respawn ( )

Ask to respawn when dead.

Definition at line 66 of file ConnectionClient.cpp.

References network_manager.

Referenced by Botcraft::ManagersClient::Handle().

◆ SendChatCommand()

void Botcraft::ConnectionClient::SendChatCommand ( const std::string &  command)

Send a command in the game chat.

Parameters
commandThe command to send (with no / at start)

Definition at line 58 of file ConnectionClient.cpp.

References network_manager.

◆ SendChatMessage()

void Botcraft::ConnectionClient::SendChatMessage ( const std::string &  msg)

Send a message in the game chat.

Parameters
msgThe message to send

Definition at line 50 of file ConnectionClient.cpp.

Referenced by Botcraft::SayImpl().

◆ SetShouldBeClosed()

void Botcraft::ConnectionClient::SetShouldBeClosed ( const bool  b)

Definition at line 40 of file ConnectionClient.cpp.

Referenced by Botcraft::Disconnect().

Member Data Documentation

◆ network_manager

◆ should_be_closed


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