Example:Your CliendId is "CSK****FHQlUQZ"
#include
#include
#ifdef _WIN64
#define SDKLOADFILEDLL L"CastarSdkWin_64.dll"
#else
#define SDKLOADFILEDLL L"CastarSdkWin_386.dll"
#endif
//Declare the function pointer to start running the SDK
typedef BOOL(*endSdk)();
//Declare function pointer to end running SDK
typedef BOOL(*startSdk)(char* key);
HMODULE hand = NULL;
//Set the ClientId here
const char *keybuf = "CSK****FHQlUQZ";
void InitSDKStart() {
startSdk demoDllStart = (startSdk)GetProcAddress(hand, "startSDK");
if (demoDllStart)
{
/*
The SDK will always block when running successfully,
and will throw a Boolean error when an exception occurs.
*/
if (!demoDllStart((char *)keybuf))
{
std::cout << "startSDK Error\n";
}
}
else
{
std::cout << "startSDK Error\n";
}
}
int main(int argc, char *argv[])
{
hand = LoadLibrary(SDKLOADFILEDLL);
if (NULL == hand || INVALID_HANDLE_VALUE == hand) {
std::cout << "LoadLibrary Error\n";
return -1;
}
//The thread calls the InitSDKStart function to avoid blocking the main thread.
CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)InitSDKStart, NULL, 0, NULL);
/*
......
Handle your own business logic here
*/
//When needed, call the end function
endSdk demoDllEnd = (endSdk)GetProcAddress(hand, "stopSDK");
if (demoDllEnd)
{
demoDllEnd();
}
else
{
std::cout << "startSDK Error\n";
}
std::cout << "End SDK Demo!\n";
}
Attention:
1.The suffixes _64 and _386 correspond to 64 bit and 32-bit compilation environments, respectively. Please load the DLL appropriately according to the program compilation environment.
dependencies {
implementation(files("libs/CastarSdk.aar"))
}
(3).Add internet permission in your app module's AndroidManifest.xml file.
<uses-permission android:name="android.permission.INTERNET" />
(4).Create your Application, init sdk and start it.
Example: Your CliendId is "CSK****FHQlUQZ"
import android.app.Application
import com.castarsdk.android.CastarSdk
class MyApplication:Application() {
override fun onCreate() {
super.onCreate()
//set your ClientId and start sdk.
CastarSdk.Start(this,"CSK****FHQlUQZ")
}
}
(5).Declare your application in your AndroidManifest.xml file.
<application
android:icon="@mipmap/ic_launcher"
android:label="demo"
android:name=".MyApplication"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.Test2"
tools:targetApi="31"<
</application<
Optional APIs
Start service
CastarSdk.start()
Stop service
CastarSdk.Stop()
Example: Your CliendId is "CSK****FHQlUQZ"
import UIKit
import SunClientSDK
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
// Set ClientId
let key = "CSK****FHQlUQZ"
/// Initialize SDK and set key
ClientSDKTool.initSDK(key: key)
// start sdk
ClientSDKTool.start()
// stop sdk
// ClientSDKTool.stop()
}
}
Step 5:SDK API
(1) Start the SDK
// Start the SDK
ClientSDKTool.start()
(2) Stop the SDK when you need to do.
// Stop the SDK
ClientSDKTool.stop()
dependencies {
implementation(files("libs/CastarSdk.aar"))
}
(3).Add internet permission in your app module's AndroidManifest.xml file.
<uses-permission android:name="android.permission.INTERNET" />
(4).Create your Application and init sdk
Example:Your CliendId is "CSK****FHQlUQZ"
import android.app.Application
import com.castarsdk.android.CastarSdk
class MyApplication:Application() {
override fun onCreate() {
super.onCreate()
//set your ClientId and start sdk.
CastarSdk.Start(this,"CSK****FHQlUQZ")
}
}
(5).Declare your application in your AndroidManifest.xml file.
<application
android:icon="@mipmap/ic_launcher"
android:label="demo"
android:name=".MyApplication"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.Test2"
tools:targetApi="31"<
</application<
Optional APIs
Start service
CastarSdk.start()
Stop service
CastarSdk.Stop()
CPU architectures: Executable program
linux/386 : CastarSdk_386
linux/amd64 : CastarSdk_amd64
linux/arm : CastarSdk_arm
(2) Grant the program executable permissions, for example.
chmod +x client_386
or
chmod +x client_amd64
or
chmod +x client_arm
(3) Launch the program
Example:Your CliendId is "CSK****FHQlUQZ"
./client_386 -key=CSK****FHQlUQZ
or
./client_arm -key=CSK****FHQlUQZ
or
./client_amd64 -key=CSK****FHQlUQZ