goblint / GobPie

Goblint IDE integration via MagpieBridge
MIT License
5 stars 3 forks source link

Replace hand-rolled JSON-RPC handling with proper library #37

Closed sim642 closed 2 years ago

sim642 commented 2 years ago

Currently all the JSON-RPC handling between GobPie and Goblint has been hand-rolled on top of a socket, JSON (de)serialization and manual reading/writing. As the number of requests increases (especially for CFG and state lookups), there will be many requests and their responses will have to be associated by ID to return them to the right places.

Instead of reinventing the wheel, we should just use lsp4j's JSON-RPC support which MagPie itself uses as well. This should allow calling JSON-RPC methods just like calling any other Java method (and the library takes care of the rest), putting the RPC into JSON-RPC for real. It also implements distributing incoming responses by ID to their callers via CompletableFuture, so instead of blocking socket reads there is asynchronicity.