Synchronous handling
hovi opened this issue · 4 comments
Hi,
I am trying to use your library to control a game. TCP server is collecting JSON requests in into queue, which are then handled in game loop in it's own thread, which is different to the thread for collecting incoming data. So what I need is to handle requests from the queue synchronously and in my own thread, otherwise I am running into race conditions and game is crashing randomly.
I am not C# developer and I don't have much knowledge of the library, but I was able to achieve what I need by basically using JsonRpcProcessor.ProcessInternal
, since that method is synchronous, returning just string. But since the method is private (and some of methods in that method), I couldn't use it directly. I had to copy and modify it and run my own version.
So please correct me if my approach is incorrect.
- Couldn't this private method
ProcessInternal
be renamed toProcessSync
or something similar and made public? - Is there any specific reason why it's private?
- If I am mistaken, what is correct way to call the library passing request
JSON
string and getting responseJSON
in same thread synchronously?
Cheers!
You are correct, there is nothing preventing ProcessInternal from being made public. Or creating a function such as ProcessSync
that calls it.
If you want to do so I'm accepting pull requests.