Background
...
- arg: object – containing:
- version: string – release number (following semantic versioning)
- localtime: string – local time of the device (ISO8601) “YYYY-MM-DDTHH:mm:ss.sssZ”
Testing
You can test your heartbeat by posting to port 443 on https://dev.exhibition.tepapa.govt.nz/heartbeat/<product-name>
Please note this is an interim testing endpoint using SSL - you do not need to support SSL in your interactive, an HTTP endpoint will be available soon.
Unity3D Example Code
As an example, we used the following example as an implementation prototype to send a heartbeat request to Te Papa's HTTP monitoring endpoint.
Parameters
- bodyJson: string - the JSON string of the payload following the implementation specification
- heartbeatURL: string - URL, incl. protocol, domain name/IP, post and path on server
- heartbeatTimeout: int - HTTP timeout (in seconds)
Please consider that heartbeatURL
and heartbeatTimeout
shall be configurable as well as the interval (in seconds) of the heartbeat.
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
[...]
byte[] bodyRaw = System.Text.Encoding.UTF8.GetBytes( bodyJson );
UnityWebRequest request = new UnityWebRequest( heartbeatURL, "POST");
request.uploadHandler = new UploadHandlerRaw(bodyRaw);
request.downloadHandler = new DownloadHandlerBuffer();
request.chunkedTransfer = false;
request.timeout = heartbeatTimeout;
request.SetRequestHeader("Content-Type", "application/json");
yield return request.SendWebRequest();
if (request.isNetworkError || request.isHttpError) {
if (!request.error.Contains("no data in response")) {
Debug.Log("Heartbeat:" + request.error));
}
}
[...] |