A GameShield SDK includes two core methods: initEx and GetProxyTcpByDomain. This topic describes how to use core methods. It also includes the details of each method.

initEx

You can call the initEx method to initialize an SDK when using the SDK for the first time. We recommend that you repeat the call for the method until a value of 0 is returned.

The following table illustrates the parameters of the initEx method. It also includes the description of each parameter.

Parameter Description
access_key The AccessKey pair that is used to access GameShield. You can download the AccessKey pair from the GameShield console. For more information, see Obtain an SDK package and AccessKey pair.
token The player ID in the game. You can use the parameter to identify a malicious player or attacker when a game application is experiencing DDoS attacks. Default value: Default.

GetProxyTcpByDomain

You can call the GetProxyTcpByDomain method to retrieve callback IP addresses. It can also be used to retrieve random port numbers by using synchronized blocks.

The following describes the feature of the GetProxyTcpByDomain method.

  • The IP address and port number for each return value are the same when the specified request parameters for each call are the same. This occurs within the lifecycle of an application after you start the application.
  • The converted IP address and port number that are returned from a call remain unchanged. This occurs within the lifecycle of an application after you start the application. GameShield automatically checks the availability of returned IP addresses and port numbers. Based on the results, GameShield automatically switches between nodes.
  • The returned IP address and port number changes after you start the application again.
  • The return value of the Target_ip parameter is set to 127.0.0.1. The IP address that is returned from the GetProxyTcpByDomain method remains unchanged. However, the port number that is returned is randomly generated.

The following table describes the parameters of the GetProxyTcpByDomain method.

Parameter Description
Token The player ID in the game. It is used to identify the malicious gamers or hackers who conduct DDoS attacks. Default value: Default.
GroupName The node group name of a game, for example, access.v812vCOE21.aliyundoc.com. In the GameShield console, you must configure node groups after you add a game and an application. For each node group, you determine the number of nodes based on the number of simultaneous gamers. You can specify multiple node groups for each game.
Dip The protection target ID, which is the IP address of the origin server. GameShield converts the IP address to a fixed IP address. You can obtain a protection target ID on the homepage of the GameShield console.
Dport The port number of the origin server. The port is randomly generated. You do not need to configure the port number in the GameShield console.
target_ip The returned IP address. The IP address is set to 127.0.0.1.
target_port The randomly generated port number that is returned.