This topic describes how to use a C++ compiler in Windows to integrate GameShield
SDK for Windows.
Procedure
- Open a C++ compiler in Windows.
- Create a project of the Console App type. In this example, the project is named yxd_windows_sdk_test.
- Add dependencies to the libs directory.
- Create a directory named libs in the project directory.
- Copy the YunCeng-WINDOWS.lib file from the Windows SDK package to the libs directory.
- Open the Property page of the project, choose , and then add ./libs as an additional library directory.
- Choose and add YunCeng.WINDOWS.lib as an additional dependency.
- Add header files and write test code.
char appkey[] = "testgroupid";
eAlSdkRet ret = YunCeng_InitEx(appkey, "token");
if (ret != cAlSdkOK) {
printf("init sdk failed.\n");
return -1;
}
- Move the YunCeng-WINDOWS.dll file to the directory where the project executable file resides. In this example,
the executable file is yxd_windows_sdk_test.exe.
- Check whether you can obtain the IP address of a game client.
/*
ret = YunCeng_GetProxyTcpByIp("token","groupId", "192.168.0.1","80", ip,ip_len, port,port_len); */
ret= YunCeng_GetProxyTcpByDomain("token","groupId", "www.aliyundoc.com","80", ip, ip_len, port,port_len);
if (ret != cAlSdkOK) {
printf("get next ip failed. \n");
} else {
printf("get next ip success. %s %s\n", ip, port);
}