Terra Streaming Protocol

SDK Reference

Identify Data Schema

Field NameTypeDescription
tokenStringAuthentication token generated from the appropriate endpoint.
typeIntegerConnection type. Value from the IdentifyType enum.

IdentifyType Enum

NameValue
User (Producer)0
Developer (Consumer)1

Payload Format

Field NameTypeDescription
opIntegerOpcode for the payload.
d?ObjectEvent data.
uid?*StringUser ID that the event relates to.
seq?*LongSequence number of the payload. Used when replaying missed payloads.
t?*StringThe Data Type for the payload.

Key:
? -> Optional field
* -> Only send with payloads of the DISPATCH opcode

{
  "op": 5,
  "d": {
    "ts": "2022-05-04T10:26:11.268507+01:00",
	"val": 95
	},
  "uid": "8e864e3a-979a-4d04-b4e9-b6d020f20ba0",
  "seq": 73,
  "t": "HEART_RATE"
}

Opcodes

NameValueDescriptionSent By
HEARTBEAT0Fired periodically by the client to keep the connection alive.Client
HEARTBEAT_ACK1Sent by the server to acknowledge that a heartbeat has been received.Server
HELLO2Sent by the server immediately after connecting. Contains the heartbeat interval for the client to use.Server
IDENTIFY3Sent by the client to complete the handshake with the server. Contains authentication details.Client
READY4Sent by the server once the handshake has been completed. The client will be able to receive/send payloads immediately after this is received.Server
DISPATCH5An event dispatched by the server. Contains details about the event, as well as the data payload for the event.Server
SUBMIT6Sent by the client to notify the server of new data which will then be routed to the correct consumer appropriately.Client (producer only)
REPLAY7Request a replay of payloads after the given lower bound, and optionally before a given upper bound.Client (consumer only)

Data Types

NameDescription
HEART_RATEval is the BPM of each reading
STEPSval the amount of accumulated steps
DISTANCEval the accumulated distance in meters
FLOORS_CLIMBEDval the accumulated floors climbed
STEPS_CADENCE val the amount of steps per second taken by the user
SPEEDval the speed in meter per second of the user
ACCELERATIONd the acceleration data of the device.
- d[0] -> acceleration in x direction
- d[1] -> acceleration in y direction
- d[2] -> acceleration in z direction
GYROSCOPEd the rotation rate af the device.
- d[0] -> rotation in x direction
- d[1] -> rotation in y direction
- d[2] -> rotation in z direction

Close Codes

CodeReason
1001Server is shutting down
1007Invalid or unrecognised JSON data was provided
4000IDENTIFY payload expected but was not received
4001Improper token was passed for IDENTIFY
4002Duplicate connection opened
4003Multiple IDENTIFY payloads received
4004Unrecognised opcode was received