Game Shield SDK Access Guide: Complete Integration Tutorial from Scratch (2025 Latest Edition)

Jun 24, 202517 mins read

?2025 latest version of the game shield SDK access strategy!

887ee453-6fb8-4d17-aefc-dc882c32144a_conew1
CDN5CDN5Game Shield consists of three core subsystems: "Secure access client components (SDK, shelling, etc.), "Secure access server room cluster", and "Single instance control panel". By integrating the secure access component, the user changes the mode of directly connecting the back-end application service from the original client program to the client connecting the local secure access component through the local IP address starting with 127. The secure access component will dynamically select the link with the least delay to forward the data to the secure access computer room server cluster, and then forward the data to the user's back-end application server cluster.  

? Core features?  

  • CDN5 game shield is a new generation of intelligent distributed cloud access system. The access node adopts a multi-computer room cluster deployment mode. In the event of a computer room failure or attack causing link congestion, the access channel will automatically be adjusted to other smooth nodes.
  • The user connection status is synchronized in real time between computer rooms. The user has no perception during node switching, and the user's TCP and UDP connections are kept uninterrupted.
  • Deployed on the basis of multi-computer room, multi-line and high protection, the overall protection capability of DDOS exceeds 2TB, which can effectively eliminate large-traffic DDOS attacks. All connections will be verified through encryption to check the authenticity of the connection, filter out all unreal connections, realize large-scale diversified CC attacks to be blocked without errors, and effectively avoid leakage of IP addresses of the user server, effectively preventing the server from being invaded.
  • The client component opens multipath at the same time and selects the optimal path for data forwarding. When the selected optimal path fluctuates, it will automatically reselect other new optimal paths. No matter where your server is, it can be accessed through the "CDN5" platform.
  • Reduce greatly the investment in access node services and reduce server and operation and maintenance costs.
  • Provides access statistics logs and analysis, such as: user distribution areas, usage periods, historical online numbers, etc., effectively helping customers achieve accurate operations.
  • Provides various forms of client components for user integration, packaging (shelling) integration, reference (calling) integration, SDK (development) integration and other methods.
  • Supported clients: Windows, Linux, Unix, IOS, Android.
  • Supported server-side: all server-side applications based on TCP and UDP.
  • Provided by a professional and technical team, 7x24 hours of real-time response in 365 days, helping users solve all problems encountered in order, configuration, integration and operation in a timely manner.

sdk instructions

Windows provides interfaces in the form of dynamic library dlls.

IOS provides interfaces in the form of static library.a or dynamic library.

Android provides interfaces in the form of aar or jar packages, and also supports dynamic libraries that directly call .so in C or C++; supports U3D, Cocos, uniapp and other developments.

Integration of sdk is very convenient, and you only need to call the "start" function in the interface (some systems are clickStart). The prototype of the function is as follows: int start(string key)    
key: is the SDK key, which can be obtained from the "Single Instance Control Panel".    
   
⚠️Note: If the key is incomplete or incorrect when called, the program will crash. If the key is deleted, the application using the key will not be able to pass the verification of the game shield, so after the key is deleted, the key configured in the original application must also be replaced. The same key will be different from the last time when each click to obtain, but the keys obtained last time are also available. Although their ciphertext content is different, they are actually the same key.Because we use dynamic encryption, the ciphertext content after each encryption is different.    

After integration, you need to go to the "Single Instance Control Panel" to configure the corresponding forwarding rules according to your application. Change the IP and port of the client program that originally directly connects to the server to the IP and port that start with 127 in the forwarding rule.    

File directory description: "Game Shield sdk\lib"The following are the sdk files corresponding to each operating system, "Game Shield sdk\demo" and "Game Shield sdk\demo Advanced Functions" are different development languages ​​written by us under the operating systems sdk integration sample code. If you have any questions, please contact our customer service.  

?Windows version integration

Windows version file description?:    
"Game Shield sdk\lib\windows\x86\clinkAPI.dll" is 32-bit dll    
"Game Shield sdk\lib\windows\x64\clinkAPI.dll" is 64-bit dll    
"Game Shield sdk\lib\windows\ClinkAPI.h"is an interface header file  

Windows version interface description?:    
Prototype of function: extern "C" CLINKAPI_API int clickStart(const char * key)  
Function: Start the client secure access component (it only needs to be called once, and there will be no errors when repeated calls. When calling, it will determine whether it has been started. If it has been started, it will directly return the result of the first call. When calling, it will return 0 due to the client network blockage. When the network is normal, we will automatically reconnect. Another call will return 150. At this time, if the service is not called, it can also run normally)  .  
Parameters:Sdk configuration key. The key is incomplete or wrong and the program will crash.  

?​​Return: 150  means success, and Other values ​​are all failed.  

  • ✔️ ​​150: Success
  • ​​0: The network is blocked
  • ​​1: It has been stopped externally (if the stop function is called, the function generally does not need to be called)
  • ​​​​​​​​​​​​​​​​​​​​​​​​​​​​2: It has been stopped internally (such as the key being deleted during operation, etc.)
  • ​​170: The instance expires or the key does not exist

?It is best to call this function first after the process is started, so that all subsequent connections can be forwarded through the secure access component. Note: Only when using C++ can the functions in this dll be called normally only when compiling in Release mode.Exe compiled in Debug mode or running in development tools will report an error  

?Sample code:

 #include #include
comment(lib, "../../../../../lib/windows/x86/clinkAPI.lib") #include "../../../../../lib/windows/clinkAPI.h" //Includes the api header file using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
/*If the compiled newspaper string is too long, you can write the following code in multiple lines, such as: char* key = "AsqaO5ZoKFpJphMAAJpHsItVh6E/J67eQ" "lX602sE1W3amXPuWYxvXrV6+bbv2p4...";*/
char* key = "Ai9oW..."; //Define the sdk key. Available from the sdk key list in the single instance control panel. Int ret = clickStart(key); //Start (only call once, and there will be no errors when repeated calls)
if (ret == 150)
{
}
else
{
}
cout << "Shield started successfully. ret=" <

? IOS static library version integration

If your project cannot use the static library version, you can choose to use the dynamic library version.

IOS static library version file description?:  

✅"Game Shield sdk\lib\IOS\IOS Static Library Version\Real Machine\libclinkAPI.a"is the true machine runtime library    
"Game Shield sdk\lib\IOS\IOS Static Library Version\Real Machine Bitcode\libclinkAPI.a"is the true machine Bitcode Runtime Library    
"Game Shield sdk\lib\IOS Static Library Version\Simulator and Real Machine\libclinkAPI_x86_arm.a"For True and Emulator Runtime Library    
"Game Shield sdk\lib\IOS Static Library Version\Simulator and Real Machine Bitcode\libclinkAPI_x86_arm.a"For real machine and emulator Bitcode Runtime Library    
"Game Shield sdk\lib\IOS Static library version\ClinkAPI.hpp"is an interface header file  

Interface description?:  

?Interface class:  
class ClinkAPI  
{  
public:  
int start(const char * key);  
};  
int start(const char * key);  
};  
};  
};  
};  
};  
};  
Prototype of function: int start(const char * key)  .
Function: Start the client secure access component (it only needs to be called once, and there will be no errors when repeated calls. When calling, it will determine whether it has been started. If it has been started, it will directly return the result of the first call. When calling, it returns 0 due to the client network blockage. When the network is normal, we will automatically reconnect. At this time, the call will return 150. If the service is not called, it can also run normally)  .
Parameters:Sdk configuration key. The key is incomplete or wrong and the program will crash.  

?​​Return: 150  means success, and Other values ​​are all failed.  

  • ✔️ ​​150: Success
  • ​​0: The network is blocked
  • ​​1: It has been stopped externally (if the stop function is called, the function generally does not need to be called)
  • ​​​​​​​​​​​​​​​​​​​​​​​​​​​​2: It has been stopped internally (such as the key being deleted during operation, etc.)
  • ​​170: The instance expires or the key does not exist

?It is best to call the function first after the process is started, so that all subsequent connections can be forwarded through the secure access component.  

?How to introduce an interface into a project:    
1. Open your project with Xcode.    
2. Drag the file of libclinkAPI_x86_arm.a (select the corresponding version according to your specific situation) directly into your project.    
3. Copy the ClinkAPI.hpp file to the project directory.    
4. Change the .m file to call the interface to .mm with the extension (the dynamic library version does not need to be modified), Otherwise, it cannot be compiled, because if the file is .m the compiler will be called in c instead of c++.    
⚠️Note: If you set Enable Bitcode to yes (the default is yes), and the library used is not a Bitcode version will report an error. There are two solutions: You can set the project Enable Bitcode to no or use the Bitcode version of the library. Some higher versions of xcode report errors when running the emulator because cpu is M1, and arm64 is required to add to Build Settings->Architectures->Excluded Architectures (Manual input).  

?Sample code:

#import "ViewController.h"
#include "ClinkAPI.hpp"//Includes the api header file @interface ViewController ()
@end
@implementation ViewController
- (void)viewDidLoad { [super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
UITextField *txtMsg = [[UITextField alloc] init]; [self.view addSubview:txtMsg];
txtMsg.frame = CGRectMake(50, 60, 170, 40); txtMsg.layer.borderWidth = 1.0; // The width of the border
txtMsg.layer.borderColor = [UIColor blueColor].CGColor; // The color of the border
txtMsg.placeholder = @"Returned status";
char* key="Ai9oW..."; //Define the sdk key. Available from the sdk key list in the single instance control panel. ClinkAPI api api;//Define the API object
int ret= api.start(key); //Start (only call once, and there will be no errors when repeated calls) txtMsg.text=[NSString stringWithFormat:@"Shield Start Return:%d",ret];
/*Change the IP of the client originally connected to the server side to the IP with 127 that starts with 127 configured in the "Instance Forwarding Rules" (for example, the forwarding rule is configured to be 127.0.0.1:7000 to 202.23.56.9:7000, and the original code is connected to 202.23.56.9:7000, and now it needs to be changed to 127.0.0.1:7000).
Integration is complete.
For details, please refer to the following two lines of pseudo-code connect("202.23.56.9", 7000) Connection before the shield is not integrated connect("127.0.0.1", 7000) Connection after the shield is integrated
*/
//If you have any questions, please contact CDN5 customer service
}
- (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@end

?IOS dynamic library version integration

IOS dynamic library version file description?:  

✅"Game Shield sdk\lib\IOS\IOS Dynamic library version\Real machine\clinkFrwAPI.framework"It is a real machine runtime library    
"Game Shield sdk\lib\IOS\IOS Dynamic library version\Real machine Bitcode\clinkFrwAPI.framework"It is a true machine Bitcode runtime library    
"Game Shield sdklib\IOS\IOS Dynamic Library Version\Simulator\clinkFrwAPI.framework"is the simulator runtime library    
"Game Shield sdk\lib\IOS\IOS Dynamic Library Version\ClinkFrwAPI.hpp"is the interface header file  

is the interface header file  

IOS dynamic library version interface description?:  

Prototype of the function: extern "C" int clickStart(const char * key).    
Function: Start the client secure access component (it only needs to be called once, and there will be no errors when repeated calls. When calling, it will determine whether it has been started. If it has been started, it will directly return the result of the first call. When calling, it returns 0 because the client network is blocked. When the network is normal, we will automatically reconnect. At this time, the call will return 150. If the service is not called, it can also run normally)  
Parameters:Sdk configuration key. The key is incomplete or wrong and the program will crash.  

?​​Return: 150  means success, and Other values ​​are all failed.  

  • ✔️ ​​150: Success
  • ​​0: The network is blocked
  • ​​1: It has been stopped externally (if the stop function is called, the function generally does not need to be called)
  • ​​​​​​​​​​​​​​​​​​​​​​​​​​​​2: It has been stopped internally (such as the key being deleted during operation, etc.)
  • ​​170: The instance expires or the key does not exist

?It is best to call the function first after the process is started, so that all subsequent connections can be forwarded through the secure access component. ​  

?How to introduce interfaces into a project (Xcode Version 11.5     As an example):    
1. Copy the clickFrwAPI.framework to your project path.    
2. Enter TARGETS >Your project name  > General > Frameworks, Libraries, and Embedded Content menu, click +, then click Add Other… to add the SDK file you just copied to the project.    
3. After adding it, set the Embed property to Embed & Sign to make the SDK dynamic library and application signature consistent.    
4. Copy the ClinkFrwAPI.hpp file to the project directory.    
?How to introduce interfaces into a project (Xcode Version 8.3.3       As an example):    
1. Copy the clickFrwAPI.framework to your project path.    
2. Enter the TARGETS > Your project name > General > Embedded Binaries menu, click +, and then click Add Other… to add the SDK file you copied to the project.    
3. Copy the ClinkFrwAPI.hpp file to the project directory.  

⚠️Note:

If you set Enable Bitcode to yes (the default is yes), the library used is not Bitcode The version will report an error. There are two solutions: You can set the project Enable Bitcode to no or use the Bitcode version of the library.    
Some higher versions of xcode report errors when running the emulator because the cpu is M1, and you need to add arm64 to Build Settings->Architectures->Excluded Architectures (Manual input).    
?When you encounter an error like this when compiling?:    
Undefined symbols for architecture arm64:  And there is declaration possible missing extern "C"    
Undefined symbols for architecture arm64:  And there is declaration possible missing extern "C"    
need to use  sdk\lib\IOS\IOS dynamic library version\contains externC header\ClinkFrwAPI.hpp , and covers the clinkFrwAPI.framework\Headers\ClinkFrwAPI.hpp clinkFrwAPI.framework\Headers\ClinkFrwAPI.hpp 和项目目录下的ClinkFrwAPI.hpp  文件,共两处。这个问题在cocos开发的项目集成时遇到过。  

?示例代码:

#import "ViewController.h"
#include "ClinkFrwAPI.hpp"//包含api头文件@interface ViewController ()
@end
@implementation ViewController
- (void)viewDidLoad { [super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
UITextField *txtMsg = [[UITextField alloc] init]; [self.view addSubview:txtMsg];
txtMsg.frame = CGRectMake(50, 60, 170, 40); txtMsg.layer.borderWidth = 1.0; // The width of the border
txtMsg.layer.borderColor = [UIColor blueColor].CGColor; // 边框的颜色
txtMsg.placeholder = @"Returned status";
char* key="Ai9oW..."; //Define the sdk key. Available from the sdk key list in the single instance control panel.以实际为准int ret= clinkStart(key); //启动(只需要调用一次,重复调用也不会出错) txtMsg.text=[NSString stringWithFormat:@"盾启动返回:%d",ret];
/*Change the IP of the client originally connected to the server side to the IP with 127 that starts with 127 configured in the "Instance Forwarding Rules" (for example, the forwarding rule is configured to be 127.0.0.1:7000 to 202.23.56.9:7000, and the original code is connected to 202.23.56.9:7000, and now it needs to be changed to 127.0.0.1:7000).
Integration is complete.
For details, please refer to the following two lines of pseudo-code connect("202.23.56.9", 7000) Connection before the shield is not integrated connect("127.0.0.1", 7000) Connection after the shield is integrated
*/
//If you have any questions, please contact CDN5 customer service
}
- (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@end

?IOS Swift 动态库版本集成

IOSSwift动态库版本文件说明?:  

✅“游戏盾 sdk\lib\IOS\IOS 动态库版本\真机\clinkFrwAPI.framework”为真机运行库    
✅“游戏盾 sdk\lib\IOS\IOS 动态库版本\真机Bitcode\clinkFrwAPI.framework”为真机Bitcode 运行库    
✅“游戏盾 sdklib\IOS\IOS 动态库版本\模拟器\clinkFrwAPI.framework”为模拟器运行库    
✅“游戏盾 sdk\lib\IOS\IOS 动态库版本\ClinkFrwAPI.hpp”为接口头文件    
✅“游戏盾 sdk\lib\IOS\IOS 动态库版本\ClinkAPISwift-Bridging-Header.h”为 Swift 桥接文件  

IOS Swift动态库版本接口说明?:  

函数的原型:extern "C" int clinkStart(const char * key)。    
功能:启动客户端安全接入组件(只需要调用一次,重复调用也不会出错,调用时内部会判断是否已启动过,如果已启动过直接返回第一次调用的结果。调用时因客户端网络不通返回了 0,等网络正常后我们会自动重连,这时再调用会返回 150,这时如果没有调用业务也可正常运行) 。   
参数:Sdk配置密钥。 key 不完整或错误,程序会崩溃。  

?​​返回:150  表示成功,其它的值均为失败  

  • ✔️ ​​150:成功
  • ​​0:网络不通
  • ​​1:已外部停止(如调用了停止函数,该函数一般不需要调用)
  • ​​2:已内部停止(如运行过程中密钥被删除等)
  • ​​170:实例到期或密钥不存在

?最好是在进程启动后先调用该函数,这样后面的所有连接都可以通过安全接入组件进行数据转发。 ​  

?如何将接口引入到项目中(Xcode Version 14.3  为例):    
1.将 clinkFrwAPI.framework 拷贝到你的工程路径下。    
2.进入TARGETS >你的项目名称> General > Frameworks, Libraries, and Embedded Content 菜单, 点击 +,再点击Add Other…,将刚才拷贝到工程下的 SDK 文件添加进去。    
3.添加进去后要将Embed 属性设置为Embed & Sign,以使得 SDK 动态库和应用签名保持一致。    
4.把 ClinkFrwAPI.hpp 文件拷贝到项目的目录下。    
5.把桥接文件 ClinkAPISwift-Bridging-Header.h 拷贝到项目的目录下。    
6.进入TARGETS >你的项目名称>BuildSettings >Swift Compiler – General 在 Objective-C Bridging Header 里把 ${SRCROOT}/你的项目名/ClinkAPISwift-Bridging-Header.h 设置进去。  

CDN5游戏盾SDK接入指南
⚠️注意

如果在真机运行项目把 Enable Bitcode 设成 yes(默认就为 yes),用的库又是非 Bitcode 版本的运行会报错, 解决办法有两个:可以将项目 Enable Bitcode 设成 no 或用Bitcode 版本的库。    
有些高版本的 xcode 在模拟器运行报错,是因为 cpu 是 M1 的,需要在 Build Settings->Architectures-> Excluded Architectures 中加上 arm64 (手动输入)    

?示例代码:

import UIKit
class ViewController: UIViewController { override func viewDidLoad() {
super.viewDidLoad()
let txtMsg = UITextField() view.addSubview(txtMsg)
txtMsg.frame = CGRectMake(50, 60, 170, 40) txtMsg.layer.borderWidth = 1.0 // 边框的宽度txtMsg.layer.borderColor = UIColor.blue.cgColor // 边框的颜色txtMsg.placeholder = "返回的状态"
let key = "Ai9oW..." //定义sdk密钥。 Available from the sdk key list in the single instance control panel.以实际为准let ret = clinkStart(key) //启动(只需要调用一次,重复调用也不会出错)
txtMsg.text = "盾启动返回:" + "\(ret)"
/*Change the IP of the client originally connected to the server side to the IP with 127 that starts with 127 configured in the "Instance Forwarding Rules" (for example, the forwarding rule is configured to be 127.0.0.1:7000 to 202.23.56.9:7000, and the original code is connected to 202.23.56.9:7000, and now it needs to be changed to 127.0.0.1:7000).
Integration is complete.
For details, please refer to the following two lines of pseudo-code connect("202.23.56.9", 7000) Connection before the shield is not integrated connect("127.0.0.1", 7000) Connection after the shield is integrated
*/
//If you have any questions, please contact CDN5 customer service
}
}

?Android版本集成【AndroidStudio】

Android版本文件说明?:  

✅“游戏盾 sdk\lib\android\clinkapi-release.aar”为包含真机和模拟器运行库  

Android版本接口说明?:  

接口类:com.dun.clinkapi.Api    
函数的原型:int start(String key)    
功能:启动客户端安全接入组件(只需要调用一次,重复调用也不会出错,调用时内部会判断是否已启动过,如果已启动过直接返回第一次调用的结果。调用时因客户端网络不通返回了 0,等网络正常后我们会自动重连,这时再调用会返回 150,这时如果没有调用业务也可正常运行) 。   
参数:Sdk配置密钥。 key 不完整或错误,程序会崩溃。  

?​​返回:150  表示成功,其它的值均为失败  

  • ✔️ ​​150:成功
  • ​​0:网络不通
  • ​​1:已外部停止(如调用了停止函数,该函数一般不需要调用)
  • ​​2:已内部停止(如运行过程中密钥被删除等)
  • ​​170:实例到期或密钥不存在

?最好是在进程启动后先调用该函数,这样后面的所有连接都可以通过安全接入组件进行数据转发。 ​  

?如何将接口引入到项目中:    
1. 用 AndroidStudio 将你的项目打开。    
2. 把clinkapi-release.aar拷贝到模块libs文件夹下。    
3. 在模块的build.gradle中的dependencies节点下增加sdk的引用:implementation files('libs/clinkapi-release.aar')    
游戏盾SDK接入指南:从零开始的完整集成教程(2025最新版)
打开 AndroidManifest.xml 增加网络访问权限    
anzuo2sfxe23
?示例代码:

package com.dun.clinkapicall;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.TextView;
public class MainActivity extends AppCompatActivity { com.dun.clinkapi.Api api = null;//定义api对象@Override
protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main);
TextView tvState = (TextView) findViewById(R.id.tvState);
String key = "Ai9oW..."; //定义sdk密钥。 Available from the sdk key list in the single instance control panel.
api = new com.dun.clinkapi.Api();//创建api对象
int ret = api.start(key); //启动(只需要调用一次,重复调用也不会出错)
tvState.setText("启动盾返回:" + ret);
/*将客户端原来连接到服务器端的IP改成“实例转发规则”配置的那个以127开头的IP(例如转发规则里配置的是127.0.0.1:7000转到202.23.56.9:7000,原先的代码里连接的是202.23.56.9:7000,现  在要改成连接127.0.0.1:7000),集成完成。
For details, please refer to the following two lines of pseudo-code connect("202.23.56.9", 7000) Connection before the shield is not integrated connect("127.0.0.1", 7000) Connection after the shield is integrated
*/
//If you have any questions, please contact CDN5 customer service
}
@Override
public void onBackPressed() { System.exit(0);
}
}

?Android版本集成【Eclipse

Android Eclipse版本文件说明?:  

✅“游戏盾 sdk\lib\android\jar\clinkapi-release.jar”接口 jar 包    
“游戏盾 sdk\lib\android\jar\armeabi\libclinkapi-lib.so”真机和模拟器运行库    
“游戏盾 sdk\lib\android\jar\x86\libclinkapi-lib.so”模拟器运行库  

Android Eclipse版本接口说明?:  

接口类:com.dun.clinkapi.Api    
函数的原型:int start(String key)    
功能:启动客户端安全接入组件(只需要调用一次,重复调用也不会出错,调用时内部会判断是否已启动过,如果已启动过直接返回第一次调用的结果。调用时因客户端网络不通返回了 0,等网络正常后我们会自动重连,这时再调用会返回 150,这时如果没有调用业务也可正常运行) 。   
参数:Sdk配置密钥。 key 不完整或错误,程序会崩溃。  

?​​返回:150  表示成功,其它的值均为失败  

  • ✔️ ​​150:成功
  • ​​0:网络不通
  • ​​1:已外部停止(如调用了停止函数,该函数一般不需要调用)
  • ​​2:已内部停止(如运行过程中密钥被删除等)
  • ​​170:实例到期或密钥不存在

?最好是在进程启动后先调用该函数,这样后面的所有连接都可以通过安全接入组件进行数据转发。 ​  

?如何将接口引入到项目中:  

1.在工程里新建 libs 文件夹,将开发包里的 clinkapi-release.jar 拷贝到 libs 根目录下,如果真机运行就将 armeabi\libclinkapi-lib.so 拷贝到 libs\armeabi\libclinkapi-lib.so 目录下, 如果是在模拟器里运行就将 x86\libclinkapi-lib.so 拷贝到 libs\x86\libclinkapi-lib.so 目录下。完成后的工程目录如下图所示:  

anzuocdsd1
2.在工程属性->Java Build Path->Libraries 中选择“ Add External JARs ”, 选定clinkapi-release.jar,确定后返回。通过以上两步操作后,您就可以正常使用CDN游戏盾 SDK为您提供的功能了。    
3.打开 manifest.xml 增加网络访问权限  

sdfsdfsdf26266

?示例代码:

package com.dun.clinkapitest; import com.dun.clinkapitest.R;
import android.support.v7.app.ActionBarActivity; import android.os.Bundle;
import android.view.Menu; import android.view.MenuItem; import android.widget.TextView;
public class MainActivity extends ActionBarActivity {
com.dun.clinkapi.Api api = null;//定义 api 对象
@Override
protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main);
TextView tvState = (TextView) findViewById(R.id.tv);
String key = "Ai9oW..." ; //定义sdk密钥。 Available from the sdk key list in the single instance control panel.
api = new com.dun.clinkapi.Api();//创建api对象
int ret = api.start(key); //启动(只需要调用一次,重复调用也不会出错)
tvState.setText("返回:" + ret);
/*将客户端原来连接到服务器端的IP改成“实例转发规则”配置的那个以127开头的IP(例如转发规则里配置的是127.0.0.1:7000转到202.23.56.9:7000,原先的代码里连接的是202.23.56.9:7000,现在
要改成连接127.0.0.1:7000),集成完成。
For details, please refer to the following two lines of pseudo-code connect("202.23.56.9", 7000) Connection before the shield is not integrated connect("127.0.0.1", 7000) Connection after the shield is integrated
*/
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present. getMenuInflater().inflate(R.menu.main, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml. int id = item.getItemId();
if (id == R.id.action_settings) { return true;
}
return super.onOptionsItemSelected(item);
}
@Override
public void onBackPressed() {
// TODO Auto-generated method stub
System.exit(0);;
}
}​

⚙️易语言版本集成

?示例代码:

DLL 文件引用代码:
.版本 2
.DLL 命令 clinkStart, 整数型, "clinkAPI.dll", "@clinkStart"
.参数 文本, 文本型
执行 DLL 命令函数:
clinkStart (“key”)

?操作示例    
易语言程序仅能调用 32 位 clinkAPI.dll,调用时请确认 dll 是否为 32 位(lib\windows\x86\clinkAPI.dll)。 调用流程    
yi1yi2
 yi3
 

?Unity版本集成

Unity版本文件说明?:  

✅“游戏盾 sdk\lib\Unity\ClinkSDKForUnity.cs”为 C#调用的类    
“游戏盾 sdk\lib\Unity\clinkAPIForIOS.mm”为支持 ios 调用的中间接口函数    
?由于Unity 开发一般要支持 windows、IOS、Android 所以还要用到这三个版本的 sdk 文件  

Unity版本接口说明?:  

接口类:

public class ClinkSDKForUnity : MonoBehaviour
{
public static int Start(string key, out string sysName)
{
}
}

函数的原型:public static int Start(string key, out string sysName)    
功能:启动客户端安全接入组件(只需要调用一次,重复调用也不会出错,调用时内部会判断是否已启动过,如果已启动过直接返回第一次调用的结果。调用时因客户端网络不通返回了 0,等网络正常后我们会自动重连,这时再调用会返回 150,这时如果没有调用业务也可正常运行) 。   
参数:Sdk配置密钥。 key 不完整或错误,程序会崩溃。  

?​​返回:150  表示成功,其它的值均为失败  

  • ✔️ ​​150:成功
  • ​​0:网络不通
  • ​​1:已外部停止(如调用了停止函数,该函数一般不需要调用)
  • ​​2:已内部停止(如运行过程中密钥被删除等)
  • ​​170:实例到期或密钥不存在

?最好是在进程启动后先调用该函数,这样后面的所有连接都可以通过安全接入组件进行数据转发。 ​  

?如何将接口引入到项目中:  

1.把 sdk\lib\Unity\ClinkSDKForUnity.cs 文件拖到 Assets 文件夹里    
2.在 Assets 下新建 Plugins 文件夹(如果已有就不用了)    
3.把 sdk\lib\windows\x64\clinkAPI.dll 文件拖到 Plugins 文件夹里(根据你的实际情况来确定你是用 64 位版本的还是 32 位版本)    
4.在 Plugins 文件夹下新建 Android 文件夹,用来放 android 的 sdk 文件    
5.把 sdk\lib\android\clinkapi-release.aar 文件拖到 Android 文件夹里    
6.在 Plugins 文件夹下新建 IOS 文件夹,用来放 ios 的 sdk 文件;    
7.把sdk\lib\IOS\IOS 静态库版本\真机Bitcode\ libclinkAPI.a 文件拖到IOS 文件夹里(根据你实际情况来确定你用的是 Bitcode 版本还是非 Bitcode 版本);    
8.把 sdk\lib\Unity\clinkAPIForIOS.mm 文件拖到 IOS 文件夹里    
9.到此 windows 、 IOS 、Android 三个端的 sdk 就已集成好了, 你只需要调用ClinkSDKForUnity.Start(string key, out string sysName)方法就可以启动我们的 sdk 了。 下图为集成好的文件目录结构    
✨​Assets 下:  

Assets222
✨Plugins下:​​

androidsdfsfsdf
✨Android 下:

Androsfsfdsid

✨IOS 下:

ios124151

?常见问题解答:

1. 当点 Unity 开发工具里的“执行”按钮执行过,就无法删除我们 windows 版本的 sdk 文件 clinkAPI.dll或运行生成的 exe 时提示端口冲突  

这是因为点“执行”时是由 Unity 执行的,Unity 加载了我们的 clinkAPI.dll 并执行, 当你停止“执行”时 Unity 并没有退出我们的 clinkAPI.dll,所以文件被占用了而且我们的 sdk 也是在运行的。 你只要关闭 Unity 开发工具重新打开就可以了。  

2.当“执行”时出现类似下图内容:   

chinsdk

这可能是你没把 clinkAPI.dll 拖到Plugins 文件夹里,或者是选的 64 位版本或 32 位版本和你实际的项目不符,只要删除现有的 clinkAPI.dll 重新选对版本就可以了。这里要注意, 一般开发环境的操作系统是 64 位的,所以这个一般用的是 64 位版的 clinkAPI.dll,当程 序发布成 32 位时最好先把这个文件换成 32 位版本的,不然会无法调用。特别要记得如果 你的程序要发布出 32 位和 64 位两个版本,在发布前最好要先替换好对应版本的 clinkAPI.dll,当然也可以在发布后把发布的出来的 clinkAPI.dll 用正确版本替换也可以。  

3.当导出IOS 项目在xcode 里运行时出错  

这可能是 IOS 版sdk 的Bitcode 版和非Bitcode 版本没选对。如果 sdk 文件用的是 Bitcode 版本那么 xcode 里要把 Enable Bitcode 设成Yes,如果你选的是非 Bitcode 版本 xcode 里要把 Enable Bitcode 设成 No。具体项目里是选 Bitcode 版本还是非 Bitcode 版本要看你已集成的其它 sdk 选的是哪一种版本, 所有 sdk 的 Bitcode 或非 Bitcode 要一致。如果你没有集成其它的 sdk,只有我们的 sdk,两种都可以,只要在 xcode 里设对就行。 Unity 默认导出来的IOS 项目Enable Bitcode 是设为 Yes 的,也就是 Bitcode 版本。    
4.如果你的项目里 android 只能用 jar 包不能用 aar 包,我们也是支持的,只是 Unity 的不同版本有点小的区别,如 Unity2018 和 Unity2021 在用 jar 包时就有点不同。具体操作只要把上面的第 5 步操作变一下就可以了,其它的操作都一样。 Unity2018 版:把sdk\lib\android\clinkapi-release.jar 文 件 拷 贝 到 Android 文 件 夹 里 , 把sdk\lib\android\armeabi-v7a\libclinkapi-lib.so 文件拷贝到 Android 文件夹里。 Unity2021 版本:把 sdk\lib\android\jar 下的所有文件及文件夹拷贝到 Android 文件夹里。  

?示例代码:

using System.Collections;
using System.Collections.Generic; using UnityEngine;
public class CallApiTest : MonoBehaviour
{
// Start is called before the first frame update void Start()
{
}
// Update is called once per frame void Update()
{
}
void OnGUI()
{
string key = "Ai9oW..."; //定义sdk密钥。 Available from the sdk key list in the single instance control panel. string sysName = "";//返回的宏定义系统名称
int ret = ClinkSDKForUnity.Start(key, out sysName); //启动(只需要调用一次,重复调用也不会出错) string msg = "";
if (ret == 150)
msg = "盾启动成功 ret=" + ret + " sysName=" + sysName;
else
msg = "盾启动失败。ret=" + ret + " sysName=" + sysName;
GUI.Label(new Rect(100, 150, 900, 900), msg);
/*将客户端原来连接到服务器端的IP改成“实例转发规则”配置的那个以127开头的IP(例如转发规则里配置的是127.0.10.21:600转到202.23.56.9:600,原先的代码里连接的是202.23.56.9:600,现在要改成连接127.0.10.21:600),
Integration is complete.
具体的可参考下面两行伪代码connect("202.23.56.9",600) 未集成盾前的连接connect("127.0.10.21", 600) 集成盾后的连接
*/
//如有任何的疑问请联系CDN5客服
}
}

?Uni-app版本集成

我们提供的是Uni-app 的“原生代码插件”,和你用的其它的“原生代码插件”的用法是一样的。目前“原生代码插件”只支持 Android 和 IOS,不支持微信小程序等。也就是需要项目通过HBuilder原生App-云打包”生成原生 App。  

Uni-app版本文件说明?:  

✅“游戏盾 sdk\lib\uni-app\dunClinkApiForUni”为 uniapp 原生代码插件(以前叫“原生插件”)  

Uni-app版本接口说明?:  

插件 name:dunClinkApiForUni    
插件函数:start (key)    
功能:启动客户端安全接入组件(只需要调用一次,重复调用也不会出错,调用时内部会判断是否已启动过,如果已启动过直接返回第一次调用的结果。调用时因客户端网络不通返回了 0,等网络正常后我们会自动重连,这时再调用会返回 150,这时如果没有调用业务也可正常运行) 。   
参数:Sdk配置密钥。key 不完整或错误,程序会崩溃。  

?​​返回:150  表示成功,其它的值均为失败  

  • ✔️ ​​150:成功
  • ​​0:网络不通
  • ​​1:已外部停止(如调用了停止函数,该函数一般不需要调用)
  • ​​2:已内部停止(如运行过程中密钥被删除等)
  • ​​170:实例到期或密钥不存在

?最好是在进程启动后先调用该函数,这样后面的所有连接都可以通过安全接入组件进行数据转发。  

?如何将接口引入到项目中:  

1.把sdk\lib\uni-app\dunClinkApiForUni 文件夹拷贝到项目的nativeplugins 文件夹下(如果没有就新建),文件夹“dunClinkApiForUni”名称不能改它表示插件的 ID  

游戏盾SDK接入指南:从零开始的完整集成教程
2.点选“manifest.json”文件->App 原生插件配置->选择本地插件,在出来的插件列里选上 dunClinkApiForUni 插件,点“确定”,到此插件就已集成到项目中了,接下来调用插件里提供的函数就可以了  

uisapp1
⚠️关键调用代码只有三行:

​const api = uni.requireNativePlugin('dunClinkApiForUni');//获取插件对象
let key ="Ai9oW...";//定义 sdk 密钥,值可从单实例控制面板的 sdk 密钥列表中获取
let ret = api.start(key);//启动客户端安全接入组件

?常见问题:

如果在开发过程中需要电脑连接手机进行调试的,需要先“制作自定义调试基座”,再“运行项目中”选“使用自定义基座运行”,不能使用“标准基座运行”,因为“标准基座”没有我们的 sdk,所以也就调不到我们的函数了。

在插件或 manifest.json 有变化时需要重新“制作自定义调试基座”。 手机上原来的版本也最好卸载调,因为在更新手机上的基座时是通过版本名称来判断要不要更新的,如果新生成的基座版本没比手机上的大将不会更新手机上的基座,只更新里面的资源。 下图为制作自定义调试基座:

usdfsd45562def1
sfsdfdsfun

?下图为使用自定义基座运行:

jjjsdfs1
??我们建议您先用 android 测试全部功能没问题后,再来通过 HBuilder“发行->原生App- 云打包”生成出ios 真机版本来测试,因为 ios 里我们放的是真机库所以只能真机运行。  

?示例代码:

具体的示例项目在:“sdk\demo\uni-app\clinkAPIcallForUniApp”以下是示例中的代码:  

相关推荐 
游戏盾SDK高级功能指南 

联系CDN5客服获取实例集成开发包:点击联系  

Image NewsLetter
Icon primary
Newsletter

Subscribe to our current affairs newsletter

By clicking the button, you are agreeing with our Term & Conditions