Diarkis C++Client Library API Document
DiarkisUdpBase Class Reference

Base class that wraps the IDiarkisUdp class for easy use of UDP functionality. More...

#include <DiarkisUdpBase.h>

Collaboration diagram for DiarkisUdpBase:

Public Member Functions

 DiarkisUdpBase ()
 DiarkisUdpBase constructor. More...
 
virtual ~DiarkisUdpBase ()
 DiarkisUdpBase destructor. More...
 
virtual void Setup (const std::shared_ptr< LoggerFactory > &loggerFactory)
 Setup function. More...
 
bool Connect (const char *endpoint, const char *clientKey, const struct AuthInfo *auth)
 Connect with UDP server. More...
 
bool Connect (const std::string &endpoint, const std::string &clientKey, const struct AuthInfo *auth)
 Same as Connect(const char*, const char*, const struct AuthInfo*) More...
 
bool Connect (const char *endpoint, const std::string &clientKey, const std::vector< uint8_t > &sid, const std::vector< uint8_t > &key, const std::vector< uint8_t > &iv, const std::vector< uint8_t > &mackey)
 Connect with UDP server. More...
 
bool ConnectAsync (const char *endpoint, const char *clientKey, const struct AuthInfo *auth)
 Connect to the server using the async thread. More...
 
bool ConnectAsync (const std::string &endpoint, const std::string &clientKey, const struct AuthInfo *auth)
 Same as ConnectAsync() More...
 
bool ConnectDualModeAsync (const char *endpoint, const char *clientKey, const struct AuthInfo *auth)
 Attemps to connect to the server by async using socket dual mode (explicit support for IPv6) turned on. GetConnectedEvent will be invoked if connection is successfully made. When connected to the server with this method, P2P is disabled. More...
 
bool ConnectDualModeAsync (const std::string &endpoint, const std::string &clientKey, const struct AuthInfo *auth)
 Same as ConnectDualModeAsync() More...
 
bool IsConnected ()
 Whether or not you are connected to the UDP server. More...
 
bool IsAsyncConnectRunning () const
 Check whether the async connection process is running. More...
 
bool GetAsyncConnectResult (System::Result &result) const
 Get the result of the async connect process. More...
 
void Disconnect ()
 Disconnect the UDP server. More...
 
void Update ()
 Update function that calls UDP processing in the client library. Must be called periodically. More...
 
void SetSchedulerAddNotifyEvent (std::function< void()> notifyEventFunc)
 Set a function to run when an event related to UDP has been added to the scheduler. More...
 
bool IsOffline ()
 Whether the UDP server is preparing for shutdown. More...
 
std::shared_ptr< IDiarkisUdpGet ()
 Get a pointer to IDiarkisUdp. More...
 
void GetGlobalAddress (Diarkis::StdString &address)
 Get own external IP address. More...
 
bool GetLocalAddress (Diarkis::StdVector< Diarkis::StdString > &addressLists)
 Get own local IP address. More...
 
bool SendPing (void)
 Ping UDP server. More...
 
bool SendEcho (void)
 Send echo to UDP server. More...
 
bool SendMigrate (void)
 Attempts to change the current connection to a differernt server. More...
 
void ClearUdpBuffer (void)
 Clear send and receive buffer of Socket. More...
 
bool SetSendThreadParam (const DiarkisThreadScheduler &scheduler)
 Specifies the priority of the UDP sending thread. More...
 
bool SetRecvThreadParam (const DiarkisThreadScheduler &scheduler)
 Specifies the priority of the UDP receive thread. More...
 
Result SendCheckNATType ()
 Sends a command to the server to check the client's NAT type. The callback event registered with IDiarkisUdp::GetCheckNATTypeEvent (e.g. OnCheckNATType) is triggered. More...
 

Protected Member Functions

virtual void OnConnect (const DiarkisConnectionEventArgs &args)
 Callback function called when connecting to the server. More...
 
virtual void OnDisconnect (bool isReconnect)
 Callback function called when disconnect from the server. More...
 
virtual void OnOffline (void)
 Callback function called when the server prepares to shutdown. More...
 
virtual void OnResponse (const DiarkisResponseEventArgs &args, DiarkisTransportType tt)
 Callback function called when a response is received from the server. More...
 
virtual void OnPush (const DiarkisPushEventArgs &args, DiarkisTransportType tt)
 Callback function called when a push is received from the server. More...
 
virtual void OnEcho (const DiarkisUdpEchoEventArgs &args)
 Callback function called when a echo is received from the server. More...
 
virtual void OnPing (const DiarkisUdpPingEventArgs &args)
 Callback function called when a ping is received from the server. More...
 
virtual void OnNotification (const DiarkisPushEventArgs &args)
 Callback function called when a notification is received from the server. More...
 
virtual void OnCheckNATType (const DiarkisCheckNATTypeEventArgs &args)
 Callback event triggered by a SendCheckNATType response. More...
 
bool SetConnectionInfo (const char *clientKey, const uint8_t *sid, size_t sidSize, const uint8_t *key, size_t keySize, const uint8_t *iv, size_t ivSize, const uint8_t *mackey, size_t mackeySize)
 Set the information for connecting to UDP server. More...
 
bool SetConnectionInfo (const Diarkis::StdString &clientKey, const AuthInfo &auth)
 Set the information for connecting to UDP server. More...
 

Protected Attributes

std::shared_ptr< IDiarkisUdpudp_
 Pointer to IDiarkisUdp class. More...
 
std::shared_ptr< IDiarkisLoggerlogger_
 Pointer to IDiarkisLogger class. More...
 
Diarkis::StdVector< std::function< void()> > eventUnsubscriptions_
 List of lambda functions. More...
 
std::function< void()> schedulerAddNotifyEventFunc_
 Sets the process to be called when UDP related events are added to a scheduler. More...
 
bool bOffline_
 Whether the server is getting ready to shut down. More...
 
Diarkis::StdString ownGlobalAddress_
 My global IP address. More...
 

Detailed Description

Base class that wraps the IDiarkisUdp class for easy use of UDP functionality.

Constructor & Destructor Documentation

◆ DiarkisUdpBase()

DiarkisUdpBase::DiarkisUdpBase ( )

DiarkisUdpBase constructor.

◆ ~DiarkisUdpBase()

DiarkisUdpBase::~DiarkisUdpBase ( )
virtual

DiarkisUdpBase destructor.

Member Function Documentation

◆ Setup()

void DiarkisUdpBase::Setup ( const std::shared_ptr< LoggerFactory > &  loggerFactory)
virtual

Setup function.

Register loggers and callback functions.

Parameters
[in]loggerFactoryPointer to logger class
Here is the call graph for this function:

◆ Connect() [1/3]

bool DiarkisUdpBase::Connect ( const char *  endpoint,
const char *  clientKey,
const struct AuthInfo auth 
)

Connect with UDP server.

Parameters
[in]endpointUDP server address
[in]clientKeyClient key
[in]authAuthentication information
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Connect() [2/3]

bool DiarkisUdpBase::Connect ( const std::string &  endpoint,
const std::string &  clientKey,
const struct AuthInfo auth 
)

Same as Connect(const char*, const char*, const struct AuthInfo*)

Here is the call graph for this function:

◆ Connect() [3/3]

bool DiarkisUdpBase::Connect ( const char *  endpoint,
const std::string &  clientKey,
const std::vector< uint8_t > &  sid,
const std::vector< uint8_t > &  key,
const std::vector< uint8_t > &  iv,
const std::vector< uint8_t > &  mackey 
)

Connect with UDP server.

Parameters
[in]endpointUDP server address
[in]clientKeyClient key
[in]sidSession ID
[in]keyEncryption key
[in]ivEncryption initialization vector (IV)
[in]mackeyMAC key
Here is the call graph for this function:

◆ ConnectAsync() [1/2]

bool DiarkisUdpBase::ConnectAsync ( const char *  endpoint,
const char *  clientKey,
const struct AuthInfo auth 
)

Connect to the server using the async thread.

This method will be finished in a short time after launching the async connection process.
You can use IsAsyncConectRunning() and GetAsyncConnectResult() to get the status of the async connection process or the result.

Parameters
[in]endpointUDP server address
[in]clientKeyClient key
[in]authAuthentication information
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ConnectAsync() [2/2]

bool DiarkisUdpBase::ConnectAsync ( const std::string &  endpoint,
const std::string &  clientKey,
const struct AuthInfo auth 
)

Same as ConnectAsync()

Here is the call graph for this function:

◆ ConnectDualModeAsync() [1/2]

bool DiarkisUdpBase::ConnectDualModeAsync ( const char *  endpoint,
const char *  clientKey,
const struct AuthInfo auth 
)

Attemps to connect to the server by async using socket dual mode (explicit support for IPv6) turned on. GetConnectedEvent will be invoked if connection is successfully made. When connected to the server with this method, P2P is disabled.

Parameters
[in]endpointUDP server address
[in]clientKeyClient key
[in]authAuthentication information
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ConnectDualModeAsync() [2/2]

bool DiarkisUdpBase::ConnectDualModeAsync ( const std::string &  endpoint,
const std::string &  clientKey,
const struct AuthInfo auth 
)

Same as ConnectDualModeAsync()

Here is the call graph for this function:

◆ IsConnected()

bool DiarkisUdpBase::IsConnected ( )

Whether or not you are connected to the UDP server.

◆ IsAsyncConnectRunning()

bool DiarkisUdpBase::IsAsyncConnectRunning ( ) const

Check whether the async connection process is running.

Returns
true when the async connection process is running

◆ GetAsyncConnectResult()

bool DiarkisUdpBase::GetAsyncConnectResult ( System::Result result) const

Get the result of the async connect process.

Parameters
[out]resultSystem::Result of the async connect process
Returns
Whether the method process successfully

◆ Disconnect()

void DiarkisUdpBase::Disconnect ( )

Disconnect the UDP server.

Here is the call graph for this function:

◆ Update()

void DiarkisUdpBase::Update ( )

Update function that calls UDP processing in the client library. Must be called periodically.

◆ SetSchedulerAddNotifyEvent()

void DiarkisUdpBase::SetSchedulerAddNotifyEvent ( std::function< void()>  notifyEventFunc)

Set a function to run when an event related to UDP has been added to the scheduler.

◆ IsOffline()

bool DiarkisUdpBase::IsOffline ( )

Whether the UDP server is preparing for shutdown.

◆ Get()

std::shared_ptr< IDiarkisUdp > DiarkisUdpBase::Get ( )

Get a pointer to IDiarkisUdp.

◆ GetGlobalAddress()

void DiarkisUdpBase::GetGlobalAddress ( Diarkis::StdString address)

Get own external IP address.

◆ GetLocalAddress()

bool DiarkisUdpBase::GetLocalAddress ( Diarkis::StdVector< Diarkis::StdString > &  addressLists)

Get own local IP address.

◆ SendPing()

bool DiarkisUdpBase::SendPing ( void  )

Ping UDP server.

When a response is received from the server a callback event (e.g. OnPing) registered with GetPingEvent() is triggered.

◆ SendEcho()

bool DiarkisUdpBase::SendEcho ( void  )

Send echo to UDP server.

When a response is received from the server a callback event (e.g. OnEcho) registered with GetEchoEvent() is triggered.

◆ SendMigrate()

bool DiarkisUdpBase::SendMigrate ( void  )

Attempts to change the current connection to a differernt server.

SID, encryption key, IV, and MAC key are maintained after migration.

◆ ClearUdpBuffer()

void DiarkisUdpBase::ClearUdpBuffer ( void  )

Clear send and receive buffer of Socket.

◆ SetSendThreadParam()

bool DiarkisUdpBase::SetSendThreadParam ( const DiarkisThreadScheduler scheduler)

Specifies the priority of the UDP sending thread.

Specifies the priority of the UDP sending thread. If set, must be called before the Connect() function.
If not called, OS standard thread policy and priority are applied.
policy is a valid setting only for Unix systems, and does not affect Windows even if it is specified.

Parameters
[in]schedulerThread scheduling settings. Set policy, priority, and affinity mask.

◆ SetRecvThreadParam()

bool DiarkisUdpBase::SetRecvThreadParam ( const DiarkisThreadScheduler scheduler)

Specifies the priority of the UDP receive thread.

Specifies the priority of the UDP receive thread. If set, must be called before the Connect() function.
If not called, OS standard thread policy and priority are applied.
policy is a valid setting only for Unix systems, and does not affect Windows even if it is specified.

Parameters
[in]schedulerThread scheduling settings. Set policy, priority, and affinity mask.

◆ SendCheckNATType()

Result DiarkisUdpBase::SendCheckNATType ( )

Sends a command to the server to check the client's NAT type. The callback event registered with IDiarkisUdp::GetCheckNATTypeEvent (e.g. OnCheckNATType) is triggered.

◆ OnConnect()

void DiarkisUdpBase::OnConnect ( const DiarkisConnectionEventArgs args)
protectedvirtual

Callback function called when connecting to the server.

Here is the call graph for this function:

◆ OnDisconnect()

void DiarkisUdpBase::OnDisconnect ( bool  isReconnect)
protectedvirtual

Callback function called when disconnect from the server.

Here is the call graph for this function:

◆ OnOffline()

void DiarkisUdpBase::OnOffline ( void  )
protectedvirtual

Callback function called when the server prepares to shutdown.

◆ OnResponse()

void DiarkisUdpBase::OnResponse ( const DiarkisResponseEventArgs args,
DiarkisTransportType  tt 
)
protectedvirtual

Callback function called when a response is received from the server.

Here is the call graph for this function:

◆ OnPush()

void DiarkisUdpBase::OnPush ( const DiarkisPushEventArgs args,
DiarkisTransportType  tt 
)
protectedvirtual

Callback function called when a push is received from the server.

Here is the call graph for this function:

◆ OnEcho()

void DiarkisUdpBase::OnEcho ( const DiarkisUdpEchoEventArgs args)
protectedvirtual

Callback function called when a echo is received from the server.

Here is the call graph for this function:

◆ OnPing()

void DiarkisUdpBase::OnPing ( const DiarkisUdpPingEventArgs args)
protectedvirtual

Callback function called when a ping is received from the server.

Here is the call graph for this function:

◆ OnNotification()

void DiarkisUdpBase::OnNotification ( const DiarkisPushEventArgs args)
protectedvirtual

Callback function called when a notification is received from the server.

Here is the call graph for this function:

◆ OnCheckNATType()

void DiarkisUdpBase::OnCheckNATType ( const DiarkisCheckNATTypeEventArgs args)
protectedvirtual

Callback event triggered by a SendCheckNATType response.

Here is the call graph for this function:

◆ SetConnectionInfo() [1/2]

bool DiarkisUdpBase::SetConnectionInfo ( const char *  clientKey,
const uint8_t *  sid,
size_t  sidSize,
const uint8_t *  key,
size_t  keySize,
const uint8_t *  iv,
size_t  ivSize,
const uint8_t *  mackey,
size_t  mackeySize 
)
protected

Set the information for connecting to UDP server.

Parameters
[in]clientKeyClient key
[in]sidSession ID
[in]sidSizeLength of the sid
[in]keyEncryption key
[in]keySizeLength of the key
[in]ivEncryption initialization vector (IV)
[in]ivSizeLength of the iv
[in]mackeyMAC key
[in]mackeySizeLength of the mackey
Here is the call graph for this function:
Here is the caller graph for this function:

◆ SetConnectionInfo() [2/2]

bool DiarkisUdpBase::SetConnectionInfo ( const Diarkis::StdString clientKey,
const AuthInfo auth 
)
protected

Set the information for connecting to UDP server.

Parameters
[in]clientKeyClient key
[in]authAuthentication information
Here is the call graph for this function:

Member Data Documentation

◆ udp_

std::shared_ptr<IDiarkisUdp> DiarkisUdpBase::udp_
protected

Pointer to IDiarkisUdp class.

◆ logger_

std::shared_ptr<IDiarkisLogger> DiarkisUdpBase::logger_
protected

Pointer to IDiarkisLogger class.

◆ eventUnsubscriptions_

Diarkis::StdVector<std::function<void()> > DiarkisUdpBase::eventUnsubscriptions_
protected

List of lambda functions.

◆ schedulerAddNotifyEventFunc_

std::function<void()> DiarkisUdpBase::schedulerAddNotifyEventFunc_
protected

Sets the process to be called when UDP related events are added to a scheduler.

◆ bOffline_

bool DiarkisUdpBase::bOffline_
protected

Whether the server is getting ready to shut down.

◆ ownGlobalAddress_

Diarkis::StdString DiarkisUdpBase::ownGlobalAddress_
protected

My global IP address.


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