I can send
Code:
{"id":1,"jsonrpc":"2.0","method":"Input.Home"}and receive
Code:
{"id":1,"jsonrpc":"2.0","result":true}This works with no problems. The issue arises when I receive notifications. These can arrive unpredictably and at any time. If a notification has been sent by XBMC, I receive multiple JSON requests at once. E.g.
{"jsonrpc":"2.0","method":"GUI.OnScreensaverActivated","params":{"data":null,"sender":"xbmc"}}{"jsonrpc":"2.0","method":"GUI.OnScreensaverDeactivated","params":{"data":null,"sender":"xbmc"}}
This causes a crash in JSON.NET, and understandably so. My first instinct is I need to asynchronously receive these notifications so that I don't have to wait until the next method is called to receive them. However this complicates the simple example I showed above because I can no longer utilize the synchronous calls. i.e.
Code:
SendJson(json);
result = ReceiveJson();Is there a clean way to implement this without over complicating it? Any/All advice is appreciated.


![[Image: badge.gif]](http://www.ohloh.net/projects/9132/badge.gif)
Search
Help