Initialization and Termination of Diarkis Module
This page introduces part of the code from the directmessage_simple
sample to explain the overall flow when using the Diarkis Module.
The actual source code of the sample is located at samples\directmessage_simple\directmessage_simple.cpp
.
Initialization of Diarkis Runtime Library and Diarkis Module
First, call DiarkisInterfaceBase::DiarkisInit()
to initialize the Diarkis Runtime Library and Diarkis Module.
This process must be executed only once at the very start across the entire application.
Creating an Instance of DiarkisInterfaceBase
Next, create an instance of a class that inherits from DiarkisInterfaceBase
to connect to the Diarkis server and use various functionalities of Diarkis.
At this time, pass the UID (User ID)
used to connect to the Diarkis server.
Initialization of Low-Level Communication Layer
After creating an instance of DiarkisInterfaceBase
, set up TCP/UDP communication used for communicating with the Diarkis server.
Obtaining Connection Information to Diarkis Server
Next, obtain the information required to connect to the Diarkis server. (TODO) Want to briefly explain client keys and server types, etc. In the accompanying sample, two patterns are implemented: obtaining connection information from the HTTP server within the Diarkis cluster and obtaining it via an API server (external server).
Pattern for Obtaining Connection Information from HTTP Server within Diarkis Cluster
Use DiarkisInterfaceBase::GetEndpoint()
to obtain the connection information.
The obtained connection information is automatically stored within DiarkisInterfaceBase
and is used when connecting.
Although not used in the sample,
DiarkisInterfaceBase::RequestEndpointAsync()
DiarkisInterfaceBase::GetEndpointAsyncStatus()
DiarkisInterfaceBase::GetAsyncEndpointResult()
can also be used to obtain endpoint information asynchronously.
Pattern for Obtaining Connection Information via API Server (External Server)
Save the connection information obtained by some method, such as an API server (external server), into AuthInfo
and pass this information during the actual connection process.
Connecting to Diarkis Server
If the connection information was obtained externally, pass the obtained information at this timing. Also, since it can take some time for the connection to complete after executing the connection process, periodically check the connection status to see if the connection has completed.
Initialization for Each Module
After completing the connection to the Diarkis server, set up the modules you wish to use and perform the necessary communication processes for the application.
Disconnecting from Diarkis Server
By calling DiarkisInterfaceBase::Disconnect()
, the process of disconnecting from the Diarkis server begins.
As with the connection, since it can take time for the disconnection to be completed, check the connection status after executing the disconnection process to see if it is completed.
Releasing Used Instances
Once the disconnection from the Diarkis server is complete and DiarkisInterfaceBase
is no longer needed, release the instance.
Termination Process
At the end of the application, call DiarkisInterfaceBase::DiarkisDestroy()
to perform the overall termination process of Diarkis. This process complements DiarkisInterfaceBase::DiarkisInit()
and, like DiarkisInit
, should be called just once during the entire application lifecycle.
Last updated
Was this helpful?