![]() |
Diarkis C++Client Library API Document
|
Base class that wraps the IDiarkisUdp class for easy use of UDP functionality. More...
#include <DiarkisUdpBase.h>
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< IDiarkisUdp > | Get () |
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< IDiarkisUdp > | udp_ |
Pointer to IDiarkisUdp class. More... | |
std::shared_ptr< IDiarkisLogger > | logger_ |
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... | |
Base class that wraps the IDiarkisUdp class for easy use of UDP functionality.
DiarkisUdpBase::DiarkisUdpBase | ( | ) |
DiarkisUdpBase constructor.
|
virtual |
DiarkisUdpBase destructor.
|
virtual |
Setup function.
Register loggers and callback functions.
[in] | loggerFactory | Pointer to logger class |
bool DiarkisUdpBase::Connect | ( | const char * | endpoint, |
const char * | clientKey, | ||
const struct AuthInfo * | auth | ||
) |
Connect with UDP server.
[in] | endpoint | UDP server address |
[in] | clientKey | Client key |
[in] | auth | Authentication information |
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*)
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.
[in] | endpoint | UDP server address |
[in] | clientKey | Client key |
[in] | sid | Session ID |
[in] | key | Encryption key |
[in] | iv | Encryption initialization vector (IV) |
[in] | mackey | MAC key |
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.
[in] | endpoint | UDP server address |
[in] | clientKey | Client key |
[in] | auth | Authentication information |
bool DiarkisUdpBase::ConnectAsync | ( | const std::string & | endpoint, |
const std::string & | clientKey, | ||
const struct AuthInfo * | auth | ||
) |
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.
[in] | endpoint | UDP server address |
[in] | clientKey | Client key |
[in] | auth | Authentication information |
bool DiarkisUdpBase::ConnectDualModeAsync | ( | const std::string & | endpoint, |
const std::string & | clientKey, | ||
const struct AuthInfo * | auth | ||
) |
bool DiarkisUdpBase::IsConnected | ( | ) |
Whether or not you are connected to the UDP server.
bool DiarkisUdpBase::IsAsyncConnectRunning | ( | ) | const |
Check whether the async connection process is running.
bool DiarkisUdpBase::GetAsyncConnectResult | ( | System::Result & | result | ) | const |
Get the result of the async connect process.
[out] | result | System::Result of the async connect process |
void DiarkisUdpBase::Disconnect | ( | ) |
Disconnect the UDP server.
void DiarkisUdpBase::Update | ( | ) |
Update function that calls UDP processing in the client library. Must be called periodically.
void DiarkisUdpBase::SetSchedulerAddNotifyEvent | ( | std::function< void()> | notifyEventFunc | ) |
Set a function to run when an event related to UDP has been added to the scheduler.
bool DiarkisUdpBase::IsOffline | ( | ) |
Whether the UDP server is preparing for shutdown.
std::shared_ptr< IDiarkisUdp > DiarkisUdpBase::Get | ( | ) |
Get a pointer to IDiarkisUdp.
void DiarkisUdpBase::GetGlobalAddress | ( | Diarkis::StdString & | address | ) |
Get own external IP address.
bool DiarkisUdpBase::GetLocalAddress | ( | Diarkis::StdVector< Diarkis::StdString > & | addressLists | ) |
Get own local IP address.
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.
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.
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.
void DiarkisUdpBase::ClearUdpBuffer | ( | void | ) |
Clear send and receive buffer of Socket.
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.
[in] | scheduler | Thread scheduling settings. Set policy, priority, and affinity mask. |
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.
[in] | scheduler | Thread scheduling settings. Set policy, priority, and affinity mask. |
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.
|
protectedvirtual |
Callback function called when connecting to the server.
|
protectedvirtual |
Callback function called when disconnect from the server.
|
protectedvirtual |
Callback function called when the server prepares to shutdown.
|
protectedvirtual |
Callback function called when a response is received from the server.
|
protectedvirtual |
Callback function called when a push is received from the server.
|
protectedvirtual |
Callback function called when a echo is received from the server.
|
protectedvirtual |
Callback function called when a ping is received from the server.
|
protectedvirtual |
Callback function called when a notification is received from the server.
|
protectedvirtual |
Callback event triggered by a SendCheckNATType response.
|
protected |
Set the information for connecting to UDP server.
[in] | clientKey | Client key |
[in] | sid | Session ID |
[in] | sidSize | Length of the sid |
[in] | key | Encryption key |
[in] | keySize | Length of the key |
[in] | iv | Encryption initialization vector (IV) |
[in] | ivSize | Length of the iv |
[in] | mackey | MAC key |
[in] | mackeySize | Length of the mackey |
|
protected |
Set the information for connecting to UDP server.
[in] | clientKey | Client key |
[in] | auth | Authentication information |
|
protected |
Pointer to IDiarkisUdp class.
|
protected |
Pointer to IDiarkisLogger class.
|
protected |
List of lambda functions.
|
protected |
Sets the process to be called when UDP related events are added to a scheduler.
|
protected |
Whether the server is getting ready to shut down.
|
protected |
My global IP address.