| 265 | } |
| 266 | |
| 267 | void on_message(std::string_view msg) |
| 268 | { |
| 269 | const auto seq = jsonParse(msg, "id", 0); |
| 270 | const auto name = jsonParse(msg, "method", 0); |
| 271 | const auto args = jsonParse(msg, "params", 0); |
| 272 | if (bindings.find(name) == bindings.end()) |
| 273 | { |
| 274 | return; |
| 275 | } |
| 276 | const auto fn = bindings[name]; |
| 277 | (*fn->first)(seq, args, fn->second); |
| 278 | } |
| 279 | |
| 280 | using binding_t = std::function<void(std::string, std::string, void*)>; |
| 281 | using binding_ctx_t = std::pair<binding_t*, void*>; |