summaryrefslogtreecommitdiff
path: root/graphics/asymptote/LspCpp/src/jsonrpc/Endpoint.cpp
blob: a66108d2e54dd4c4b2b4e635fdbf130daf7d98bb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#include "LibLsp/JsonRpc/Endpoint.h"
#include "LibLsp/JsonRpc/message.h"


bool GenericEndpoint::notify(std::unique_ptr<LspMessage> msg)
{
        auto findIt = method2notification.find(msg->GetMethodType());

        if (findIt != method2notification.end())
        {
                return  findIt->second(std::move(msg));
        }
        std::string info = "can't find method2notification for notification:\n" + msg->ToJson() + "\n";
        log.log(lsp::Log::Level::SEVERE, info);
        return false;
}

bool GenericEndpoint::onResponse(const std::string& method, std::unique_ptr<LspMessage>msg)
{
        auto findIt = method2response.find(method);

        if (findIt != method2response.end())
        {
                return  findIt->second(std::move(msg));
        }

        std::string info = "can't find method2response for response:\n" + msg->ToJson() + "\n";
        log.log(lsp::Log::Level::SEVERE, info);

        return false;
}



bool GenericEndpoint::onRequest(std::unique_ptr<LspMessage> request)
{
        auto findIt = method2request.find(request->GetMethodType());

        if (findIt != method2request.end())
        {
                return  findIt->second(std::move(request));
        }
        std::string info = "can't find method2request for request:\n" + request->ToJson() + "\n";
        log.log(lsp::Log::Level::SEVERE, info);
        return false;
}