| 43 | } |
| 44 | |
| 45 | void LanguageServer::SendNotification(std::string_view method, std::shared_ptr<lsp::Serializable> param) { |
| 46 | auto json = nlohmann::json::object(); |
| 47 | json["jsonrpc"] = "2.0"; |
| 48 | json["method"] = method; |
| 49 | if (param != nullptr) { |
| 50 | json["params"] = param->Serialize(); |
| 51 | } else { |
| 52 | json["params"] = nullptr; |
| 53 | } |
| 54 | |
| 55 | if (_session) { |
| 56 | auto dumpResult = json.dump(); |
| 57 | std::string message = util::format("Content-Length:{}\r\n\r\n", dumpResult.size()); |
| 58 | |
| 59 | message.append(dumpResult); |
| 60 | _session->Send(std::move(message)); |
| 61 | } |
| 62 | } |
| 63 | |
| 64 | void LanguageServer::SendRequest(std::string_view method, std::shared_ptr<lsp::Serializable> param) { |
| 65 | auto json = nlohmann::json::object(); |