![]() |
Botcraft 1.21.4
|
#include <NetworkManager.hpp>
Public Member Functions | |
NetworkManager (const std::string &address, const std::string &login, const bool force_microsoft_auth, 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::Message > msg) |
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.
Botcraft::NetworkManager::NetworkManager | ( | const std::string & | address, |
const std::string & | login, | ||
const bool | force_microsoft_auth, | ||
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, message_sent_index, name, OnNewRawData(), Botcraft::Utilities::RSAToBytes(), Send(), state, Botcraft::Utilities::WaitForCondition(), and WaitForNewPackets().
Botcraft::NetworkManager::NetworkManager | ( | const ProtocolCraft::ConnectionState | constant_connection_state | ) |
Definition at line 99 of file NetworkManager.cpp.
References compression, and state.
Botcraft::NetworkManager::~NetworkManager | ( | ) |
Definition at line 105 of file NetworkManager.cpp.
References Stop().
void Botcraft::NetworkManager::AddHandler | ( | ProtocolCraft::Handler * | h | ) |
Definition at line 130 of file NetworkManager.cpp.
References subscribed.
Referenced by NetworkManager().
const ConnectionState Botcraft::NetworkManager::GetConnectionState | ( | ) | const |
Definition at line 171 of file NetworkManager.cpp.
References state.
const std::string & Botcraft::NetworkManager::GetMyName | ( | ) | const |
Definition at line 176 of file NetworkManager.cpp.
References name.
std::thread::id Botcraft::NetworkManager::GetProcessingThreadId | ( | ) | const |
Definition at line 294 of file NetworkManager.cpp.
References m_thread_process.
|
overrideprivatevirtual |
Definition at line 623 of file NetworkManager.cpp.
References chunk_batch_start_time, and Send().
|
overrideprivatevirtual |
Definition at line 618 of file NetworkManager.cpp.
References chunk_batch_start_time.
|
overrideprivatevirtual |
Definition at line 506 of file NetworkManager.cpp.
References Send().
|
overrideprivatevirtual |
Definition at line 590 of file NetworkManager.cpp.
|
overrideprivatevirtual |
Definition at line 431 of file NetworkManager.cpp.
References authentifier, com, and Send().
|
overrideprivatevirtual |
Definition at line 597 of file NetworkManager.cpp.
References Send().
|
overrideprivatevirtual |
Definition at line 489 of file NetworkManager.cpp.
References Send().
|
overrideprivatevirtual |
Definition at line 411 of file NetworkManager.cpp.
References compression.
|
overrideprivatevirtual |
Definition at line 419 of file NetworkManager.cpp.
|
overrideprivatevirtual |
Definition at line 561 of file NetworkManager.cpp.
References authentifier, chat_session_uuid, Botcraft::Utilities::DecodeBase64(), Botcraft::Utilities::RSAToBytes(), and Send().
|
overrideprivatevirtual |
Definition at line 604 of file NetworkManager.cpp.
References Send().
|
overrideprivatevirtual |
Definition at line 497 of file NetworkManager.cpp.
References Send().
|
overrideprivatevirtual |
|
overrideprivatevirtual |
Definition at line 635 of file NetworkManager.cpp.
References Send().
|
overrideprivatevirtual |
Definition at line 611 of file NetworkManager.cpp.
|
private |
Definition at line 401 of file NetworkManager.cpp.
References mutex_process, packets_to_process, and process_condition.
Referenced by NetworkManager().
|
private |
Definition at line 369 of file NetworkManager.cpp.
References ProtocolCraft::CreateClientboundMessage(), LOG_FATAL, state, and subscribed.
Referenced by WaitForNewPackets().
void Botcraft::NetworkManager::Send | ( | const std::shared_ptr< ProtocolCraft::Message > | msg | ) |
Definition at line 135 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 247 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 181 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 110 of file NetworkManager.cpp.
References com, compression, m_thread_process, process_condition, and state.
Referenced by ~NetworkManager().
|
private |
Definition at line 299 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 90 of file NetworkManager.hpp.
Referenced by Handle(), Handle(), NetworkManager(), SendChatCommand(), and SendChatMessage().
|
private |
Definition at line 105 of file NetworkManager.hpp.
Referenced by Handle(), SendChatCommand(), and SendChatMessage().
|
private |
Definition at line 108 of file NetworkManager.hpp.
Referenced by Handle(), and SendChatMessage().
|
private |
Definition at line 113 of file NetworkManager.hpp.
|
private |
Definition at line 89 of file NetworkManager.hpp.
Referenced by Handle(), NetworkManager(), Send(), and Stop().
|
private |
Definition at line 98 of file NetworkManager.hpp.
Referenced by Handle(), NetworkManager(), NetworkManager(), Send(), Stop(), and WaitForNewPackets().
|
private |
Definition at line 93 of file NetworkManager.hpp.
Referenced by GetProcessingThreadId(), NetworkManager(), and Stop().
|
private |
Definition at line 109 of file NetworkManager.hpp.
Referenced by NetworkManager(), and SendChatMessage().
|
private |
Definition at line 96 of file NetworkManager.hpp.
Referenced by OnNewRawData(), and WaitForNewPackets().
|
private |
Definition at line 100 of file NetworkManager.hpp.
Referenced by Send().
|
private |
Definition at line 102 of file NetworkManager.hpp.
Referenced by GetMyName(), NetworkManager(), and WaitForNewPackets().
|
private |
Definition at line 95 of file NetworkManager.hpp.
Referenced by OnNewRawData(), and WaitForNewPackets().
|
private |
Definition at line 97 of file NetworkManager.hpp.
Referenced by OnNewRawData(), Stop(), and WaitForNewPackets().
|
private |
Definition at line 91 of file NetworkManager.hpp.
Referenced by GetConnectionState(), Handle(), Handle(), NetworkManager(), NetworkManager(), ProcessPacket(), Stop(), and WaitForNewPackets().
|
private |
Definition at line 87 of file NetworkManager.hpp.
Referenced by AddHandler(), and ProcessPacket().