|
Botcraft 1.21.10
|
#include <NetworkManager.hpp>
Public Types | |
| enum class | AuthType { Offline , Microsoft , McToken } |
Public Member Functions | |
| NetworkManager (const std::string &address, const std::string &login_or_microsoft_cache_key_or_mc_token, const AuthType auth_type, const std::vector< ProtocolCraft::Handler * > &handlers={}) | |
| NetworkManager (const ProtocolCraft::ConnectionState constant_connection_state) | |
| ~NetworkManager () | |
| void | Stop () |
| void | AddHandler (ProtocolCraft::Handler *h) |
| void | Send (const std::shared_ptr< ProtocolCraft::Packet > packet) |
| const ProtocolCraft::ConnectionState | GetConnectionState () const |
| const std::string & | GetMyName () const |
| void | SendChatMessage (const std::string &message) |
| void | SendChatCommand (const std::string &command) |
| std::thread::id | GetProcessingThreadId () const |
Private Attributes | |
| std::vector< ProtocolCraft::Handler * > | subscribed |
| std::shared_ptr< TCP_Com > | com |
| std::shared_ptr< Authentifier > | authentifier |
| ProtocolCraft::ConnectionState | state |
| std::thread | m_thread_process |
| std::queue< std::vector< unsigned char > > | packets_to_process |
| std::mutex | mutex_process |
| std::condition_variable | process_condition |
| int | compression |
| std::mutex | mutex_send |
| std::string | name |
| LastSeenMessagesTracker | chat_context |
| ProtocolCraft::UUID | chat_session_uuid {} |
| std::atomic< int > | message_sent_index |
| std::chrono::steady_clock::time_point | chunk_batch_start_time |
Definition at line 24 of file NetworkManager.hpp.
|
strong |
| Enumerator | |
|---|---|
| Offline | |
| Microsoft | |
| McToken | |
Definition at line 27 of file NetworkManager.hpp.
| Botcraft::NetworkManager::NetworkManager | ( | const std::string & | address, |
| const std::string & | login_or_microsoft_cache_key_or_mc_token, | ||
| const AuthType | auth_type, | ||
| const std::vector< ProtocolCraft::Handler * > & | handlers = {} |
||
| ) |
Definition at line 25 of file NetworkManager.cpp.
References AddHandler(), authentifier, com, compression, Botcraft::Utilities::DecodeBase64(), m_thread_process, McToken, message_sent_index, Microsoft, name, Offline, OnNewRawData(), Botcraft::Utilities::RSAToBytes(), Send(), state, Botcraft::Utilities::WaitForCondition(), and WaitForNewPackets().
| Botcraft::NetworkManager::NetworkManager | ( | const ProtocolCraft::ConnectionState | constant_connection_state | ) |
Definition at line 106 of file NetworkManager.cpp.
References compression, and state.
| Botcraft::NetworkManager::~NetworkManager | ( | ) |
Definition at line 112 of file NetworkManager.cpp.
References Stop().
| void Botcraft::NetworkManager::AddHandler | ( | ProtocolCraft::Handler * | h | ) |
Definition at line 137 of file NetworkManager.cpp.
References subscribed.
Referenced by NetworkManager().
| const ConnectionState Botcraft::NetworkManager::GetConnectionState | ( | ) | const |
Definition at line 178 of file NetworkManager.cpp.
References state.
| const std::string & Botcraft::NetworkManager::GetMyName | ( | ) | const |
Definition at line 183 of file NetworkManager.cpp.
References name.
| std::thread::id Botcraft::NetworkManager::GetProcessingThreadId | ( | ) | const |
Definition at line 301 of file NetworkManager.cpp.
References m_thread_process.
|
overrideprivatevirtual |
Definition at line 648 of file NetworkManager.cpp.
References chunk_batch_start_time, and Send().
|
overrideprivatevirtual |
Definition at line 643 of file NetworkManager.cpp.
References chunk_batch_start_time.
|
overrideprivatevirtual |
Definition at line 523 of file NetworkManager.cpp.
References Send().
|
overrideprivatevirtual |
Definition at line 615 of file NetworkManager.cpp.
|
overrideprivatevirtual |
Definition at line 438 of file NetworkManager.cpp.
References authentifier, com, and Send().
|
overrideprivatevirtual |
Definition at line 622 of file NetworkManager.cpp.
References Send().
|
overrideprivatevirtual |
Definition at line 506 of file NetworkManager.cpp.
References Send().
|
overrideprivatevirtual |
Definition at line 418 of file NetworkManager.cpp.
References compression.
|
overrideprivatevirtual |
Definition at line 426 of file NetworkManager.cpp.
|
overrideprivatevirtual |
Definition at line 586 of file NetworkManager.cpp.
References authentifier, chat_session_uuid, Botcraft::Utilities::DecodeBase64(), Botcraft::Utilities::RSAToBytes(), and Send().
|
overrideprivatevirtual |
Definition at line 629 of file NetworkManager.cpp.
References Send().
|
overrideprivatevirtual |
Definition at line 514 of file NetworkManager.cpp.
References Send().
|
overrideprivatevirtual |
|
overrideprivatevirtual |
Definition at line 660 of file NetworkManager.cpp.
References Send().
|
overrideprivatevirtual |
Definition at line 636 of file NetworkManager.cpp.
|
private |
Definition at line 408 of file NetworkManager.cpp.
References mutex_process, packets_to_process, and process_condition.
Referenced by NetworkManager().
|
private |
Definition at line 376 of file NetworkManager.cpp.
References ProtocolCraft::CreateClientboundPacket(), LOG_FATAL, state, and subscribed.
Referenced by WaitForNewPackets().
| void Botcraft::NetworkManager::Send | ( | const std::shared_ptr< ProtocolCraft::Packet > | packet | ) |
Definition at line 142 of file NetworkManager.cpp.
References com, Botcraft::Compress(), compression, and mutex_send.
Referenced by Handle(), Handle(), Handle(), Handle(), Handle(), Handle(), Handle(), Handle(), Handle(), Handle(), Handle(), Handle(), NetworkManager(), SendChatCommand(), and SendChatMessage().
| void Botcraft::NetworkManager::SendChatCommand | ( | const std::string & | command | ) |
Definition at line 254 of file NetworkManager.cpp.
References authentifier, chat_context, Botcraft::LastSeenMessagesTracker::GetLastSeenMessagesUpdate(), Botcraft::LastSeenMessagesTracker::GetMutex(), and Send().
| void Botcraft::NetworkManager::SendChatMessage | ( | const std::string & | message | ) |
Definition at line 188 of file NetworkManager.cpp.
References authentifier, chat_context, chat_session_uuid, Botcraft::LastSeenMessagesTracker::GetLastSeenMessagesUpdate(), Botcraft::LastSeenMessagesTracker::GetMutex(), LOG_INFO, message_sent_index, and Send().
| void Botcraft::NetworkManager::Stop | ( | ) |
Definition at line 117 of file NetworkManager.cpp.
References com, compression, m_thread_process, process_condition, and state.
Referenced by ~NetworkManager().
|
private |
Definition at line 306 of file NetworkManager.cpp.
References compression, Botcraft::Decompress(), Botcraft::Logger::GetInstance(), LOG_FATAL, mutex_process, name, packets_to_process, process_condition, ProcessPacket(), Botcraft::Logger::RegisterThread(), and state.
Referenced by NetworkManager().
|
private |
Definition at line 96 of file NetworkManager.hpp.
Referenced by Handle(), Handle(), NetworkManager(), SendChatCommand(), and SendChatMessage().
|
private |
Definition at line 111 of file NetworkManager.hpp.
Referenced by Handle(), SendChatCommand(), and SendChatMessage().
|
private |
Definition at line 114 of file NetworkManager.hpp.
Referenced by Handle(), and SendChatMessage().
|
private |
Definition at line 119 of file NetworkManager.hpp.
|
private |
Definition at line 95 of file NetworkManager.hpp.
Referenced by Handle(), NetworkManager(), Send(), and Stop().
|
private |
Definition at line 104 of file NetworkManager.hpp.
Referenced by Handle(), NetworkManager(), NetworkManager(), Send(), Stop(), and WaitForNewPackets().
|
private |
Definition at line 99 of file NetworkManager.hpp.
Referenced by GetProcessingThreadId(), NetworkManager(), and Stop().
|
private |
Definition at line 115 of file NetworkManager.hpp.
Referenced by NetworkManager(), and SendChatMessage().
|
private |
Definition at line 102 of file NetworkManager.hpp.
Referenced by OnNewRawData(), and WaitForNewPackets().
|
private |
Definition at line 106 of file NetworkManager.hpp.
Referenced by Send().
|
private |
Definition at line 108 of file NetworkManager.hpp.
Referenced by GetMyName(), NetworkManager(), and WaitForNewPackets().
|
private |
Definition at line 101 of file NetworkManager.hpp.
Referenced by OnNewRawData(), and WaitForNewPackets().
|
private |
Definition at line 103 of file NetworkManager.hpp.
Referenced by OnNewRawData(), Stop(), and WaitForNewPackets().
|
private |
Definition at line 97 of file NetworkManager.hpp.
Referenced by GetConnectionState(), Handle(), Handle(), NetworkManager(), NetworkManager(), ProcessPacket(), Stop(), and WaitForNewPackets().
|
private |
Definition at line 93 of file NetworkManager.hpp.
Referenced by AddHandler(), and ProcessPacket().