|
Botcraft 26.3
|
#include <TCP_Com.hpp>
Public Member Functions | |
| TCP_Com (const std::string &address, std::function< void(std::vector< unsigned char >)> callback, std::function< void()> on_close_callback) | |
| ~TCP_Com () | |
| 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_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(std::vector< unsigned char >)> | NewPacketCallback |
| std::mutex | mutex_output |
| std::string | ip |
| unsigned short | port |
| std::shared_ptr< AESEncrypter > | encrypter |
| std::function< void()> | OnCloseCallback |
| bool | close_reported |
Definition at line 18 of file TCP_Com.hpp.
| Botcraft::TCP_Com::TCP_Com | ( | const std::string & | address, |
| std::function< void(std::vector< unsigned char >)> | callback, | ||
| std::function< void()> | on_close_callback | ||
| ) |
Definition at line 24 of file TCP_Com.cpp.
References close_reported, Botcraft::Logger::GetInstance(), handle_read(), io_context, ip, LOG_ERROR, LOG_INFO, NewPacketCallback, OnCloseCallback, port, read_packet, Botcraft::Logger::RegisterThread(), SetIPAndPortFromAddress(), socket, and thread_com.
| Botcraft::TCP_Com::~TCP_Com | ( | ) |
Definition at line 60 of file TCP_Com.cpp.
References io_context, and thread_com.
| void Botcraft::TCP_Com::close | ( | ) |
Definition at line 109 of file TCP_Com.cpp.
References do_close(), and io_context.
|
private |
Definition at line 222 of file TCP_Com.cpp.
References close_reported, LOG_ERROR, OnCloseCallback, and socket.
Referenced by close(), handle_read(), and handle_write().
|
private |
Definition at line 182 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 99 of file TCP_Com.cpp.
References ip.
| const unsigned short Botcraft::TCP_Com::GetPort | ( | ) | const |
Definition at line 104 of file TCP_Com.cpp.
References port.
|
private |
Definition at line 114 of file TCP_Com.cpp.
References do_close(), encrypter, handle_read(), input_packet, NewPacketCallback, read_packet, and socket.
Referenced by handle_read(), and TCP_Com().
|
private |
Definition at line 199 of file TCP_Com.cpp.
References do_close(), handle_write(), mutex_output, output_packet, and socket.
Referenced by do_write(), and handle_write().
| void Botcraft::TCP_Com::SendPacket | ( | const std::vector< unsigned char > & | bytes | ) |
Definition at line 70 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 93 of file TCP_Com.cpp.
References encrypter.
|
private |
Definition at line 246 of file TCP_Com.cpp.
References Botcraft::DNSMessage::GetAnswers(), Botcraft::DNSSrvData::GetNameLabels(), Botcraft::DNSMessage::GetNumberAnswer(), Botcraft::DNSSrvData::GetPort(), 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 71 of file TCP_Com.hpp.
Referenced by do_close(), and TCP_Com().
|
private |
Definition at line 68 of file TCP_Com.hpp.
Referenced by handle_read(), SendPacket(), and SetEncrypter().
|
private |
Definition at line 58 of file TCP_Com.hpp.
Referenced by handle_read().
|
private |
Definition at line 52 of file TCP_Com.hpp.
Referenced by close(), SendPacket(), TCP_Com(), and ~TCP_Com().
|
private |
Definition at line 64 of file TCP_Com.hpp.
Referenced by GetIp(), SetIPAndPortFromAddress(), and TCP_Com().
|
private |
Definition at line 62 of file TCP_Com.hpp.
Referenced by do_write(), and handle_write().
|
private |
Definition at line 61 of file TCP_Com.hpp.
Referenced by handle_read(), and TCP_Com().
|
private |
Definition at line 70 of file TCP_Com.hpp.
Referenced by do_close(), and TCP_Com().
|
private |
Definition at line 59 of file TCP_Com.hpp.
Referenced by do_write(), and handle_write().
|
private |
Definition at line 65 of file TCP_Com.hpp.
Referenced by GetPort(), SetIPAndPortFromAddress(), and TCP_Com().
|
private |
Definition at line 57 of file TCP_Com.hpp.
Referenced by handle_read(), and TCP_Com().
|
private |
Definition at line 53 of file TCP_Com.hpp.
Referenced by do_close(), do_write(), handle_read(), handle_write(), and TCP_Com().
|
private |
Definition at line 55 of file TCP_Com.hpp.
Referenced by TCP_Com(), and ~TCP_Com().