Quantcast
Channel: Kodi Community Forum - All Forums
Viewing all articles
Browse latest Browse all 84004

Separating responses on TCP stream?

$
0
0
Hi!

for fun, I am working on a little app that talks to the JSONRPC server of XBMC (Eden). I have picked TCP as the transport of choice, as it gives me a single connection to the server through which I can both receive notifications as well as execute methods.

All is working pretty much as expected, except that if I fire requests too quickly in succession, I'm getting some of the responses "glued" to one another in my receive buffer. Ie.

Code:
Sent:  "{ "id" : 476707713, "jsonrpc" : "2.0", "method" : "Player.GetActivePlayers" }"
Sent:  "{ "id" : 1186278907, "jsonrpc" : "2.0", "method" : "Player.GetItem", "params" : { "playerid" : 0 } }"
Sent:  "{ "id" : 505671508, "jsonrpc" : "2.0", "method" : "Player.GetProperties", "params" : { "playerid" : 0, "properties" : [ "percentage" ] } }"
Received:  "{"id":476707713,"jsonrpc":"2.0","result":[{"playerid":0,"type":"audio"}]}"
Received:  "{"id":1186278907,"jsonrpc":"2.0","result":{"item":{"id":2479,"label":"Phosphene","type":"song"}}}{"id":505671508,"jsonrpc":"2.0","result":{"percentage":32.47583770751953125}}"

If I add small delays (say 10ms) between the calls, it all executes as expected, all depending on client processing speed and network of course. But I am pretty sure this is more of race condition, and will also occur when I just receive a notification just when I receive a response as well.

So, I wonder if XBMC could somehow identify the discrete responses on the stream?

Thanks!

Ernst.

Viewing all articles
Browse latest Browse all 84004

Trending Articles