41. Client programming part 3: Client version restrictions

Client distribution times may not be precisely restricted in mobile distribution environments like Google Play or the App Store. For example, if a client updated from version 1.0 to version 1.1 is distributed through the AppStore, users may update to version 1.1 as well as version 1.0 at the same time depending on the time since their last update. To solve this problem, the game server must maintain a list of compatible client versions.

iFun Engine allows you to designate versions that are allowed access to solve this problem.

41.1. Designating compatible client versions

You can include the following data in a MANIFEST.json AppInfo session.

  • client_current_version: Designates the version string calling the newest client. E.g. “7”

  • client_compatible_versions: Designates a list of compatible client version strings, e.g. [“5”, “6”]

  • client_update_info: Designates a text string to send to an incompatible client attempting access to inform them.

  • client_update_uri: Designates a URL for incompatible clients to access to update.

41.1.1. Example

Assume the client is updated to version 17 and versions 15 and 16 are permitted, but other versions are not permitted access.

41.1.1.1. MANIFEST.json settings

{
  "client_current_version": "17",
  "client_compatible_versions": ["15", "16"],
  "client_update_info": "new version available",
  "client_update_url": "https://play.google.com/store/apps/details?id=com.example.Game1"
}

41.1.1.2. Server-side code

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
...

void OnVersionMessage(const Ptr<Session> &session, const Json &message) {
  string client_version = ...  // from client

  if (not AppInfo::client_version().IsCompatible(client_version)) {
    string update_msg = AppInfo::client_version().client_update_info();
    string update_url = AppInfo::client_version().client_update_uri();

    session->SendMessage(...);

    return;
  }
}

...
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
...

void OnVersionMessage(Session session, JObject message)
{
  string client_version = ...  // from client

  if (!AppInfo.IsCompatibleVersion (client_version))
  {
    string update_msg = AppInfo.ClientUpdateInfo;
    string update_uri = AppInfo.ClientUpdateUri;

    session.SendMessage(...);

    return;
  }
}

...