Divide Framework 0.1
A free and open-source 3D Framework under heavy development
Loading...
Searching...
No Matches
Divide::ASIO Class Referenceabstract

#include <ASIO.h>

+ Inheritance diagram for Divide::ASIO:

Public Types

using LOG_CBK = DELEGATE< void, std::string_view, bool >
 

Public Member Functions

virtual bool sendPacket (WorldPacket &p) const
 Send a packet to the target server.
 
virtual bool init (const string &address, U16 port)
 Init a connection to the target address:port.
 
virtual bool connect (const string &address, U16 port)
 
virtual void disconnect ()
 Disconnect from the server.
 
virtual bool isConnected () const noexcept
 Check connection state;.
 
virtual void toggleDebugOutput (bool debugOutput) noexcept
 Toggle the printing of debug information.
 
virtual ~ASIO ()
 

Static Public Member Functions

static void SET_LOG_FUNCTION (const LOG_CBK &cbk)
 
static void LOG_PRINT (const char *msg, bool error=false)
 

Protected Member Functions

 ASIO () noexcept=default
 
void close ()
 
virtual void handlePacket (WorldPacket &p)=0
 

Protected Attributes

boost::asio::io_context _ioService
 
std::unique_ptr< boost::asio::io_context::work > _work
 
std::unique_ptr< std::thread > _thread
 
Client_uptr _localClient
 
bool _connected {false}
 
bool _debugOutput {true}
 
string _address
 
string _port
 

Static Protected Attributes

static LOG_CBK s_logCBK
 

Friends

class Client
 

Detailed Description

Definition at line 49 of file ASIO.h.

Member Typedef Documentation

◆ LOG_CBK

using Divide::ASIO::LOG_CBK = DELEGATE<void, std::string_view , bool >

Definition at line 67 of file ASIO.h.

Constructor & Destructor Documentation

◆ ~ASIO()

Divide::ASIO::~ASIO ( )
virtual

Definition at line 19 of file ASIO.cpp.

◆ ASIO()

Divide::ASIO::ASIO ( )
protecteddefaultnoexcept

Member Function Documentation

◆ close()

void Divide::ASIO::close ( )
protected

Definition at line 87 of file ASIO.cpp.

◆ connect()

bool Divide::ASIO::connect ( const string address,
U16  port 
)
virtual

Connect to target address:port only if we have a new IP:PORT combo or our connection timed out

Definition at line 72 of file ASIO.cpp.

◆ disconnect()

void Divide::ASIO::disconnect ( )
virtual

Disconnect from the server.

Definition at line 33 of file ASIO.cpp.

◆ handlePacket()

virtual void Divide::ASIO::handlePacket ( WorldPacket p)
protectedpure virtual

Implemented in Divide::LocalClient.

◆ init()

bool Divide::ASIO::init ( const string address,
U16  port 
)
virtual

Init a connection to the target address:port.

Definition at line 44 of file ASIO.cpp.

◆ isConnected()

bool Divide::ASIO::isConnected ( ) const
virtualnoexcept

Check connection state;.

Definition at line 82 of file ASIO.cpp.

◆ LOG_PRINT()

void Divide::ASIO::LOG_PRINT ( const char *  msg,
bool  error = false 
)
static

Definition at line 123 of file ASIO.cpp.

◆ sendPacket()

bool Divide::ASIO::sendPacket ( WorldPacket p) const
virtual

Send a packet to the target server.

Definition at line 93 of file ASIO.cpp.

◆ SET_LOG_FUNCTION()

void Divide::ASIO::SET_LOG_FUNCTION ( const LOG_CBK cbk)
static

Definition at line 118 of file ASIO.cpp.

◆ toggleDebugOutput()

void Divide::ASIO::toggleDebugOutput ( bool  debugOutput)
virtualnoexcept

Toggle the printing of debug information.

Definition at line 112 of file ASIO.cpp.

Friends And Related Function Documentation

◆ Client

friend class Client
friend

Definition at line 76 of file ASIO.h.

Member Data Documentation

◆ _address

string Divide::ASIO::_address
protected

Definition at line 92 of file ASIO.h.

◆ _connected

bool Divide::ASIO::_connected {false}
protected

Definition at line 90 of file ASIO.h.

◆ _debugOutput

bool Divide::ASIO::_debugOutput {true}
protected

Definition at line 91 of file ASIO.h.

◆ _ioService

boost::asio::io_context Divide::ASIO::_ioService
protected

Definition at line 86 of file ASIO.h.

◆ _localClient

Client_uptr Divide::ASIO::_localClient
protected

Definition at line 89 of file ASIO.h.

◆ _port

string Divide::ASIO::_port
protected

Definition at line 92 of file ASIO.h.

◆ _thread

std::unique_ptr<std::thread> Divide::ASIO::_thread
protected

Definition at line 88 of file ASIO.h.

◆ _work

std::unique_ptr<boost::asio::io_context::work> Divide::ASIO::_work
protected

Definition at line 87 of file ASIO.h.

◆ s_logCBK

NO_DESTROY ASIO::LOG_CBK Divide::ASIO::s_logCBK
staticprotected

Definition at line 94 of file ASIO.h.


The documentation for this class was generated from the following files: