![]() |
Botcraft 1.21.4
|
The base client handling connection with a server. More...
#include <ConnectionClient.hpp>
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< NetworkManager > | GetNetworkManager () 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< NetworkManager > | network_manager |
bool | should_be_closed |
The base client handling connection with a server.
Only processes packets required to maintain the connection.
Definition at line 11 of file ConnectionClient.hpp.
Botcraft::ConnectionClient::ConnectionClient | ( | ) |
Definition at line 9 of file ConnectionClient.cpp.
References network_manager, and should_be_closed.
|
virtual |
Definition at line 15 of file ConnectionClient.cpp.
References Disconnect().
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.
address | Address to connect to, as written in minecraft multiplayer window |
login | If login is empty, will try to connect with a Microsoft account |
force_microsoft_account | If 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.
|
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().
std::shared_ptr< NetworkManager > Botcraft::ConnectionClient::GetNetworkManager | ( | ) | const |
Definition at line 45 of file ConnectionClient.cpp.
Referenced by Botcraft::CloseContainerImpl(), Botcraft::DigImpl(), Botcraft::EatImpl(), Botcraft::GoToImpl(), Botcraft::InteractEntityImpl(), Botcraft::InteractWithBlockImpl(), Botcraft::PlaceBlockImpl(), Botcraft::TradeImpl(), and Botcraft::TemplatedBehaviourClient< TDerived >::TreeLoop().
bool Botcraft::ConnectionClient::GetShouldBeClosed | ( | ) | const |
Definition at line 35 of file ConnectionClient.cpp.
References should_be_closed.
|
overrideprotectedvirtual |
Reimplemented in Botcraft::ManagersClient.
Definition at line 126 of file ConnectionClient.cpp.
References ProtocolCraft::Json::Value::Dump(), LOG_INFO, ProtocolCraft::NetworkType::Serialize(), and should_be_closed.
|
overrideprotectedvirtual |
Reimplemented in Botcraft::ManagersClient.
Definition at line 105 of file ConnectionClient.cpp.
References ProtocolCraft::Json::Value::Dump(), LOG_INFO, ProtocolCraft::NetworkType::Serialize(), and should_be_closed.
|
overrideprotectedvirtual |
Reimplemented in Botcraft::ManagersClient.
Definition at line 77 of file ConnectionClient.cpp.
References LOG_INFO, and should_be_closed.
Referenced by Botcraft::ManagersClient::Handle(), and Botcraft::ManagersClient::Handle().
|
overrideprotectedvirtual |
Reimplemented in Botcraft::ManagersClient, and Botcraft::ManagersClient.
Definition at line 139 of file ConnectionClient.cpp.
References network_manager.
|
overrideprotectedvirtual |
Reimplemented in Botcraft::ManagersClient, and Botcraft::ManagersClient.
Definition at line 116 of file ConnectionClient.cpp.
References network_manager.
|
overrideprotectedvirtual |
Reimplemented in Botcraft::ManagersClient, and Botcraft::ManagersClient.
Definition at line 144 of file ConnectionClient.cpp.
References network_manager.
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().
void Botcraft::ConnectionClient::SendChatCommand | ( | const std::string & | command | ) |
Send a command in the game chat.
command | The command to send (with no / at start) |
Definition at line 58 of file ConnectionClient.cpp.
References network_manager.
void Botcraft::ConnectionClient::SendChatMessage | ( | const std::string & | msg | ) |
Send a message in the game chat.
msg | The message to send |
Definition at line 50 of file ConnectionClient.cpp.
Referenced by Botcraft::SayImpl().
void Botcraft::ConnectionClient::SetShouldBeClosed | ( | const bool | b | ) |
Definition at line 40 of file ConnectionClient.cpp.
Referenced by Botcraft::Disconnect().
|
protected |
Definition at line 57 of file ConnectionClient.hpp.
Referenced by Botcraft::TemplatedBehaviourClient< TDerived >::BehaviourStep(), Connect(), ConnectionClient(), Disconnect(), Botcraft::ManagersClient::Disconnect(), Botcraft::ManagersClient::GetPlayerName(), Handle(), Botcraft::ManagersClient::Handle(), Handle(), Handle(), Botcraft::ManagersClient::Handle(), Respawn(), SendChatCommand(), and Botcraft::ManagersClient::SendInventoryTransaction().
|
protected |
Definition at line 59 of file ConnectionClient.hpp.
Referenced by Botcraft::TemplatedBehaviourClient< TDerived >::BehaviourStep(), ConnectionClient(), Disconnect(), GetShouldBeClosed(), Handle(), Handle(), Handle(), Botcraft::TemplatedBehaviourClient< TDerived >::RunBehaviourUntilClosed(), Botcraft::TemplatedBehaviourClient< TDerived >::SyncAction(), Botcraft::TemplatedBehaviourClient< TDerived >::Yield(), and Botcraft::TemplatedBehaviourClient< TDerived >::~TemplatedBehaviourClient().