loom
30 строк · 1.0 Кб
1#include "Shutdown.h"
2#include "simodo/lsp-server/ServerContext.h"
3
4#include "simodo/variable/json/Rpc.h"
5#include "simodo/variable/json/Serialization.h"
6
7namespace simodo::lsp
8{
9
10void Shutdown::work()
11{
12if (_server.state() == ServerState::Shutdown) {
13_server.log().error("There are wrong parameter structure of 'shutdown' command", variable::toJson(_jsonrpc.value()));
14/// @todo Скорректировать коды (и тексты) ошибок
15_server.sending().push(variable::JsonRpc(-1, u"Invalid request", _jsonrpc.id()));
16return;
17}
18
19if (_server.shutdown()) {
20_server.sending().push(variable::JsonRpc(variable::Value {}, _jsonrpc.id()));
21return;
22}
23
24_server.log().error("There are wrong parameter structure of 'shutdown' command", variable::toJson(_jsonrpc.value()));
25_server.sending().push(
26/// @todo Скорректировать коды (и тексты) ошибок
27variable::JsonRpc(-1, u"An exception happens during shutdown request", _jsonrpc.id()));
28}
29
30}