I am using XBMC json-rpc with websockets. When I send json request like "method":"Playlist.OnClear"
I get response {"id":1,"jsonrpc":"2.0","result":"OK"}
.
So if I'll send multiple requests I will get multiple responses and I won't be able to identify which response refers to which request. Is it possible to pass some additional data to request so that it would be added to response (like context
in jquery ajax call)?
I don't know is it related to XBMC or json-rpc in general.
Perhaps this question was not answered because it is slightly inaccurate.
Firstly there is no method "Playlist.OnClear, rather Playlist.OnClear is only a non-solicited notification from the media player, on that states the playlist was cleared. Now the playlist might clear directly as a result of another request you had made, for example Playlist.Clear comes to mind, which is indeed a method.
So when you send the valid json packet
{"jsonrpc":"2.0","method":"Playlist.Clear","params":{"playlistid":0},"id":10101}
You can use the "id" key to add a, guess what, an id to the request, and that very same id will be returned from the mediaplayer
{"id":10101,"jsonrpc":"2.0","result":"OK"}
Furthermore, it is possible to write paired web based requests/response code, but that's not even necessary considering the above...