|
Botcraft 1.21.10
|
#include <TCP_Com.hpp>
Public Member Functions | |
| TCP_Com (const std::string &address, std::function< void(const std::vector< unsigned char > &)> callback) | |
| ~TCP_Com () | |
| bool | IsInitialized () const |
| void | close () |
| void | SendPacket (const std::vector< unsigned char > &bytes) |
| void | SetEncrypter (const std::shared_ptr< AESEncrypter > encrypter_) |
| const std::string & | GetIp () const |
| const unsigned short | GetPort () const |
Private Member Functions | |
| void | handle_connect (const asio::error_code &error) |
| void | handle_read (const asio::error_code &error, std::size_t bytes_transferred) |
| void | do_write (const std::vector< unsigned char > &bytes) |
| void | handle_write (const asio::error_code &error) |
| void | do_close () |
| void | SetIPAndPortFromAddress (const std::string &address) |
Private Attributes | |
| asio::io_context | io_context |
| asio::ip::tcp::socket | socket |
| std::thread | thread_com |
| std::array< unsigned char, 512 > | read_packet |
| std::vector< unsigned char > | input_packet |
| std::deque< std::vector< unsigned char > > | output_packet |
| std::function< void(const std::vector< unsigned char > &)> | NewPacketCallback |
| std::mutex | mutex_output |
| std::string | ip |
| unsigned short | port |
| std::shared_ptr< AESEncrypter > | encrypter |
| std::atomic< bool > | initialized |
Definition at line 17 of file TCP_Com.hpp.
| Botcraft::TCP_Com::TCP_Com | ( | const std::string & | address, |
| std::function< void(const std::vector< unsigned char > &)> | callback | ||
| ) |
Definition at line 20 of file TCP_Com.cpp.
References Botcraft::Logger::GetInstance(), handle_connect(), io_context, ip, LOG_INFO, NewPacketCallback, port, Botcraft::Logger::RegisterThread(), SetIPAndPortFromAddress(), socket, and thread_com.
| Botcraft::TCP_Com::~TCP_Com | ( | ) |
Definition at line 39 of file TCP_Com.cpp.
References Botcraft::Logger::GetInstance(), thread_com, and Botcraft::Logger::UnregisterThread().
| void Botcraft::TCP_Com::close | ( | ) |
Definition at line 92 of file TCP_Com.cpp.
References do_close(), and io_context.
|
private |
Definition at line 221 of file TCP_Com.cpp.
References socket.
Referenced by close(), handle_read(), and handle_write().
|
private |
Definition at line 181 of file TCP_Com.cpp.
References handle_write(), mutex_output, output_packet, and socket.
Referenced by SendPacket().
| const std::string & Botcraft::TCP_Com::GetIp | ( | ) | const |
Definition at line 82 of file TCP_Com.cpp.
References ip.
| const unsigned short Botcraft::TCP_Com::GetPort | ( | ) | const |
Definition at line 87 of file TCP_Com.cpp.
References port.
|
private |
Definition at line 97 of file TCP_Com.cpp.
References handle_read(), initialized, LOG_ERROR, LOG_INFO, read_packet, and socket.
Referenced by TCP_Com().
|
private |
Definition at line 113 of file TCP_Com.cpp.
References do_close(), encrypter, handle_read(), input_packet, NewPacketCallback, read_packet, and socket.
Referenced by handle_connect(), and handle_read().
|
private |
Definition at line 198 of file TCP_Com.cpp.
References do_close(), handle_write(), mutex_output, output_packet, and socket.
Referenced by do_write(), and handle_write().
| bool Botcraft::TCP_Com::IsInitialized | ( | ) | const |
Definition at line 48 of file TCP_Com.cpp.
References initialized.
| void Botcraft::TCP_Com::SendPacket | ( | const std::vector< unsigned char > & | bytes | ) |
Definition at line 53 of file TCP_Com.cpp.
References do_write(), encrypter, and io_context.
| void Botcraft::TCP_Com::SetEncrypter | ( | const std::shared_ptr< AESEncrypter > | encrypter_ | ) |
Definition at line 76 of file TCP_Com.cpp.
References encrypter.
|
private |
Definition at line 226 of file TCP_Com.cpp.
References Botcraft::DNSMessage::GetAnswers(), Botcraft::DNSSrvData::GetNameLabels(), Botcraft::DNSMessage::GetNumberAnswer(), Botcraft::DNSSrvData::GetPort(), io_context, ip, LOG_INFO, LOG_WARNING, port, ProtocolCraft::NetworkType::Read(), Botcraft::DNSQuestion::SetClassCode(), Botcraft::DNSMessage::SetFlagAA(), Botcraft::DNSMessage::SetFlagOPCode(), Botcraft::DNSMessage::SetFlagQR(), Botcraft::DNSMessage::SetFlagRA(), Botcraft::DNSMessage::SetFlagRCode(), Botcraft::DNSMessage::SetFlagRD(), Botcraft::DNSMessage::SetFlagTC(), Botcraft::DNSMessage::SetFlagZ(), Botcraft::DNSMessage::SetIdentification(), Botcraft::DNSQuestion::SetNameLabels(), Botcraft::DNSMessage::SetNumberAdditionalRR(), Botcraft::DNSMessage::SetNumberAnswer(), Botcraft::DNSMessage::SetNumberAuthority(), Botcraft::DNSMessage::SetNumberQuestion(), Botcraft::DNSMessage::SetQuestions(), Botcraft::DNSQuestion::SetTypeCode(), Botcraft::Utilities::SplitString(), and ProtocolCraft::NetworkType::Write().
Referenced by TCP_Com().
|
private |
Definition at line 69 of file TCP_Com.hpp.
Referenced by handle_read(), SendPacket(), and SetEncrypter().
|
private |
Definition at line 72 of file TCP_Com.hpp.
Referenced by handle_connect(), and IsInitialized().
|
private |
Definition at line 59 of file TCP_Com.hpp.
Referenced by handle_read().
|
private |
Definition at line 53 of file TCP_Com.hpp.
Referenced by close(), SendPacket(), SetIPAndPortFromAddress(), and TCP_Com().
|
private |
Definition at line 65 of file TCP_Com.hpp.
Referenced by GetIp(), SetIPAndPortFromAddress(), and TCP_Com().
|
private |
Definition at line 63 of file TCP_Com.hpp.
Referenced by do_write(), and handle_write().
|
private |
Definition at line 62 of file TCP_Com.hpp.
Referenced by handle_read(), and TCP_Com().
|
private |
Definition at line 60 of file TCP_Com.hpp.
Referenced by do_write(), and handle_write().
|
private |
Definition at line 66 of file TCP_Com.hpp.
Referenced by GetPort(), SetIPAndPortFromAddress(), and TCP_Com().
|
private |
Definition at line 58 of file TCP_Com.hpp.
Referenced by handle_connect(), and handle_read().
|
private |
Definition at line 54 of file TCP_Com.hpp.
Referenced by do_close(), do_write(), handle_connect(), handle_read(), handle_write(), and TCP_Com().
|
private |
Definition at line 56 of file TCP_Com.hpp.
Referenced by TCP_Com(), and ~TCP_Com().