Initialization and Shutdown 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 in 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 beginning of the 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 Diarkis features.
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 the TCP/UDP communication used to communicate with the Diarkis server.
Obtaining Connection Information for the Diarkis Server
Next, obtain the information needed to connect to the Diarkis server. (TODO) Want to lightly explain items like client key and server type. The included sample implements two patterns: obtaining connection information from an HTTP server within the Diarkis cluster and obtaining connection information via an API server (external server).
Pattern to Obtain Connection Information from an HTTP Server within the Diarkis Cluster
Use DiarkisInterfaceBase::GetEndpoint()
to obtain connection information.
The obtained connection information is automatically saved within DiarkisInterfaceBase
and used when connecting.
Also, although not used in the sample
DiarkisInterfaceBase::RequestEndpointAsync()
DiarkisInterfaceBase::GetEndpointAsyncStatus()
DiarkisInterfaceBase::GetAsyncEndpointResult()
can be used to obtain endpoint information asynchronously.
Pattern to Obtain Connection Information via an API Server (External Server)
Save the connection information obtained through some method like an API server (external server) in AuthInfo
, and pass this information when actually connecting.
Connecting to Diarkis Server
If connection information was obtained externally, pass the obtained information at this time. Also, after executing the connection process, check the connection status periodically to confirm whether the connection is complete, as it may take some time until the connection is actually established.
Initialization of Each Module
After the connection to the Diarkis server is complete, set up each module you want to use and perform the necessary communication processing for the application.
Disconnecting from the Diarkis Server
Call DiarkisInterfaceBase::Disconnect()
to start the disconnection process from the Diarkis server.
As with the connection, it may take some time until the disconnection is completed, so check the connection status after executing the disconnection process to confirm whether the disconnection is complete.
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 execute the overall termination process of Diarkis. This process pairs with DiarkisInterfaceBase::DiarkisInit()
, and like DiarkisInit
, it should be called only once during the entire application lifecycle.
最終更新