Skip to content

Concurrent user API

Note

How to aggregate Concurrent User (CCU) Log provided as API format is changed. As Hive SDK sends the log to analytics server API from Hive SDK v4.14.4, game studio does not have to call the number of concurrent user anymore. Just let Hive SDK does it.

Fundamentals of CCU API

API Communication method

  • CCU API provides XML data communication by using HTTP protocol.
  • Make sure to send XML after encoding to base64.
  • Sending method is two ways: sending XML texts by using the value parameter as POST type, and sending the texts to body without any parameter.
    • PHP cURL is suitable for the method sending XML texts by using value parameter.
    • C++ or wininet is suitable for the method sending XML texts by setting post data as body without value parameter.
  • The result returns to the XML encoded to Base64. If failed to check the result, make sure to re-send it.
  • Prior to service open, test the connection on the test server. After starting the service, deliver to common server.
  • Test server should be connected while in service.
  • Send the XML by implementing API every two minutes hourly (KST). (e.g., 13:00, 13:02, 13:04 … )
  • CCU has different standard by game server.
    • Web server sends the unique number of requesting users for last two minutes.
    • Socket server sends the number of users connected with the server.

API test

PIC

Sending CCU

  • Request URL
Common URL http://api-index.qpyou.cn/modules/gameuser/currentuser/
Sandbox URL http://sandbox-api-index.withhive.com/modules/gameuser/currentuser/
HTTP Method Post
Data Format XML
Parameter value (Not used when sending post data to body e.g., C++, wininet)
  • post data
Field Name Description
game The key which distinguishes game
Make sure to request registration to PIC
e.g., Issue as tinyfarm_KR, derbydays_SEA
server Server identifier when sending user data by server
Maximum 20 characters available as a combination of alphabet and digits (set 0 if it disregards server type)
e.g.,
\0\ → Possible
\1\ → Possible
\tinyfarm01\ → Possible
reqkey Unique key of CCU
Unique key of CCU data generated by the server, which sends CCU data
Recommended encoding to MD5
reqkey guarantees the duplicate process
date The time generating CCU data
Format: yyyy-mm-dd hh🇲🇲ss (Second displays as ‘00’)
On a basis of KST, process at every two minutes, the interval of API implementation
e.g., 2016-06-23 16:24:00
user The number of CCU
  • Response
Field Name Description
result Result code. 100=Success to save See more
  • Call (Origin XML → base64 encoding → URL encoding)
xml version="1.0" encoding="utf-8" ?
tinyfarm_KR
0
c4b40eb7d241654b74ec825976f42618
2016-06-23 16:23:00
1
curl -X 
POST -d "PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiID8+CjxnYW1ldXNlcj4KPGdhbWU+dGlueWZhcm1fS1I8L2dhbWU+CjxzZXJ2ZXI+MDwvc2VydmVyPgo8cmVxa2V5PmM0YjQwZWI3ZDI0MTY1NGI3NGVjODI1OTc2ZjQyNjE4PC9yZXFrZXk+CjxkYXRlPjIwMTYtMDYtMjMgMTY6MjM6MDA8L2RhdGU+Cjx1c2VyPjE8L3VzZXI+CjwvZ2FtZXVzZXI+Cg==" http://sandbox-api-index.withhive.com/modules/gameuser/currentuser/
  • Request
> POST /modules/gameuser/currentuser/ HTTP/1.1
> Host: sandbox-api-index.withhive.com
> User-Agent: curl/7.55.1
> Accept: */*
> Content-Length: 276
> Content-Type: application/x-www-form-urlencoded
>
PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiID8+CjxnYW1ldXNlcj4KPGdhbWU+dGlueWZhcm1fS1I8L2dhbWU+CjxzZXJ2ZXI+MDwvc2VydmVyPgo8cmVxa2V5PmM0YjQwZWI3ZDI0MTY1NGI3NGVjODI1OTc2ZjQyNjE4PC9yZXFrZXk+CjxkYXRlPjIwMTYtMDYtMjMgMTY6MjM6MDA8L2RhdGU+Cjx1c2VyPjE8L3VzZXI+CjwvZ2FtZXVzZXI+Cg==
  • Response
< HTTP/1.1 200 OK
< Server: nginx/1.8.0
< Date: Wed, 13 Nov 2019 08:54:39 GMT
< Content-Type: text/html; charset=utf-8
< Transfer-Encoding: chunked
< Connection: keep-alive
<
PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiID8+PHJlc3VsdD4zMDI8L3Jlc3VsdD4=

Result code

Code Description
100 Success to save CCU data
101 Not processed due to duplicate request (duplicate reqkey)
200 Parameter error (No input data)
201 Parameter error (No required data)
202 Parameter error (Input data with wrong format)
203 Base64 Encoding Error (base64 not encoded)
204 Different format from Xml
300 DB error
301 CCU data and the sum of data are the same
e.g., server01 CCU = 100, server02 CCU = 0
Occurred when the result of (server01 CCU)+(server02 CCU) is the same as the number of server01 CCU
302 No game key