Porting your game to run in China

This page is only relevant to users deploying games to server nodes hosted in China. You can only deploy to server nodes hosted in China if you're located in China. For more information, contact your account manager or get in touch.

You can use SpatialOS to deploy games in China in almost the same way as in the rest of the world. However, because there are some differences in online access, both into and out of China, deploying a game in China that is built for the global market requires you to make some changes. This page describes how to adjust your game configuration and workflows to deploy your game in China.

The Console

The Console is the main landing page for managing cloud deployments. Access to the Console differs depending on your location:

Organizations

You need to consider how to manage your SpatialOS organization within the SpatialOS Console. The name of your organization might be different for the platform outside of China compared to the platform for China. (To see your organization, hover over your account icon in the top right of the Console.)

Developer accounts

If you have a developer member within your organization for the platform outside of China, they are not automatically added to the corresponding organization for the China platform. Each developer needs to create a separate SpatialOS account to use within the China organization. You then need to add developer accounts to the China organization just as you added them to the organization outside of China.

The SpatialOS CLI

As a team member of two organizations (outside of China and in China) you have two separate SpatialOS accounts. When you switch between the organizations, remember to log out of one account and into the other, because the accounts, and the tokens associated with them, are not interchangeable.

To use the CLI in China, you must either:

  • add --environment=cn-production to all commands, or
  • run spatial config set default-environment cn-production once, from any directory. This sets the environment for your computer, so you don’t need to specify it with every command. You can override this for a particular command only by specifying the production environment, which is the default environment outside of China. To do this, specify --environment=production for that command.

Setting up the GDK for Unreal

We have added specific instructions for developers working in China throughout our step-by-step guide to setting up and using the GDK for Unreal.

For information on the differences in the GDK for developers in China, see GDK differences in China.

Elements of your game

Game services

API endpoint

If you’re porting a game service for use in China, your game service needs to use the China platform API endpoint:

  • Address: platform.api.spatialoschina.com
  • Port 443

This applies to services you’ve created using the Platform SDK directly.

The Platform SDK defaults to using the non-China platform endpoint, but you can reconfigure it to use the China platform endpoint by changing the PlatformApiEndpoint parameter in the Create method for each service client:

Service accounts

You need to use a service account to authenticate calls to the China platform API endpoint. You need to create a separate service account for calls to the China platform endpoint. If you try to use the China platform endpoint with a service account created for the platform outside of China, the call will fail with permissions denied.

You can use the Platform SDK’s service account service (see service accounts maintenance) to create and manage a service account.

Client-workers

When porting your game client for China, you need to make some changes.

The Locator

If you’re creating a game for China using the GDK for Unreal, you don’t need to make any changes regarding the Locator.

If you’re using the Worker SDK, then when you create an instance of the Locator, you need to specify the hostname as locator.spatialoschina.com and the port as 443. For further information, see the documentation for each language:

Cloud project name

Your organization might use a different cloud project name in China compared to outside of China. If this is the case, and your client code has a dependency on the cloud project name, you need to change the project name in your code.

Player authentication

Player authentication works only if the authentication server points to the same platform that client-worker instances connect to.

When you port a game to run in China, you need to make the following changes:

  • Client-worker instances must connect to the China platform (see The Locator above).
  • When you use the PlayerAuth service, you must use the China platform to generate the PlayerIdentityTokens and LoginTokens that the game authentication service passes to client-worker instances. Otherwise, the client-worker instances won’t be able to connect to the deployment. For information on using the Platform SDK on the China platform, see API endpoint above.
  • When you use the development authentication flow for internal playtesting, you must create DevelopmentAuthenticationTokens using the CLI on the China platform (see The SpatialOS CLI above).

Server-workers

Server-workers require little or no change when you port to the China platform.

Receptionist

If you’re using the Worker SDK, server-worker instances can still connect to deployments via the Receptionist.

Refresh tokens

  • If you’re using the Platform SDK, and the launch configuration section of your server-worker type’s worker configuration file contains the argument ${IMPROBABLE_PLATFORM_REFRESH_TOKEN}, you don’t need to make any changes. (If you’re using the flexible project layout, this argument is in your server-worker type’s server-worker configuration file).

  • If you need to use a service account refresh token to allow a server-worker instance to access deployments that it’s not involved in, the service account must point to the China platform, and the organization name and cloud project name must be correct for the China platform:

    • If you’re creating the service account yourself using the Platform SDK, you need to use the China platform API endpoint (see API endpoint above) and specify the correct organization and cloud project name for the China platform.

    • If someone at Improbable is creating your service account, make sure you tell them that it’s for the China platform, and let them know the correct organization and cloud project name for the China platform.


2020-10-12: Page updated with editorial review: updated to remove reference to Online Services

Updated 11 months ago


Porting your game to run in China


Suggested Edits are limited on API Reference Pages

You can only suggest edits to Markdown body content, but not to the API spec.