Page 1 of 1

Multiple responses in one message (JavaScript only?)

PostPosted: 12 Dec 2014, 06:57
by warbyrd
Hi,

i'm trying to calibrate the EyeTribe within JavaScript.
So i send a heartbeat every 200ms.

When i start calibrating it happens, that the heartbeat-response kind of interferes with the actual interesting response.

Then something like this is the data from ONE message from the EyeTribe:

Code: Select all
{"category":"heartbeat","statuscode":200}
{"category":"tracker","request":"get","statuscode":200,"values":{"frame":{"avg":{"x":0.0,"y":0.0},"fix":false,"lefteye":{"avg":{"x":0.0,"y":0.0},"pcenter":{"x":0.3968,"y":0.3453},"
psize":20.6514,"raw":{"x":0.0,"y":0.0}},"raw":{"x":0.0,"y":0.0},"righteye":{"avg":{"x":0.0,"y":0.0},"pcenter":{"x":0.5504,"y":0.3348},"psize":16.2393,"raw":{"x":0.0,"y":0.0}},"stat
e":6,"time":1020246937,"timestamp":"2014-12-12 05:44:14.617"}}}


As i have to parse the data to a JSON Object, the Parser throws an exception and if the second message inside the above code is a calibration response the procedure gets all messed up.

So my question is, if i can somehow disable the heartbeat response as it is kinda useless and only useful for debugging.

Or are there better ways to calibrate the EyeTribe in my own app? Should i disable the push mode and just request the data every 33ms?

--
and also an offtopic question: What is the longest heartbeat interval i can set? - i mean i could just try, but if you told us all, i wouldn't have to ;)

Re: Multiple responses in one message (JavaScript only?)

PostPosted: 12 Jan 2015, 15:08
by Micky
Hi,

The EyeTribe server communicates over a raw/stream TCP socket, which by design just streams data whenever it's available. As experienced data from the server can contain multiple JSON messages, just as data may only contain a partial JSON message. To account for this count the '{' and '}' to know when a complete JSON message has been received. The SDKs are all doing exactly that.

It's currently not possible to disable the heartbeat acknowledgements from the server.

Regarding the offtopic question. It is not possible to set the heartbeat interval, it has been set by the server, but the value can be queried using:

Code: Select all
{ "category": "tracker", "request": "get", "values": [ "heartbeatinterval" ] }

which will provide the heartbeat interval in [ms]. Heartbeats need to be sent at least once within one heartbeat time interval, which, in the time of writing, corresponds to 3 seconds.