MCPcopy Create free account
hub / github.com/CppCXY/EmmyLuaCodeStyle / Run

Method Run

CodeFormatServer/src/Session/SocketIOSession.cpp:13–53  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

11}
12
13int SocketIOSession::Run(LanguageServer &server) {
14 auto &ioc = server.GetIOContext();
15 IOSession::Run(server);
16 while (true) {
17 do {
18 asio::error_code code;
19
20 char *writableCursor = _protocolBuffer.GetWritableCursor();
21 std::size_t capacity = _protocolBuffer.GetRestCapacity();
22
23 std::size_t readSize = _socket.read_some(asio::buffer(writableCursor, capacity), code);
24 if (code == asio::error::eof || code) {
25 goto endLoop;
26 }
27
28 _protocolBuffer.SetWriteSize(readSize);
29
30 if (_protocolBuffer.CanReadOneProtocol()) {
31 break;
32 }
33
34 _protocolBuffer.FitCapacity();
35 } while (true);
36
37 do {
38 auto content = _protocolBuffer.ReadOneProtocol();
39 auto parser = std::make_shared<ProtocolParser>();
40 parser->Parse(content);
41 _protocolBuffer.Reset();
42 asio::post(ioc, [this, parser, &server]() {
43 std::string result = Handle(server, parser);
44
45 if (!result.empty()) {
46 Send(result);
47 }
48 });
49 } while (_protocolBuffer.CanReadOneProtocol());
50 }
51endLoop:
52 return 0;
53}
54
55void SocketIOSession::Send(std::string_view content) {
56 asio::write(_socket, asio::buffer(content));

Callers

nothing calls this directly

Calls 13

bufferFunction · 0.85
postFunction · 0.85
GetWritableCursorMethod · 0.80
GetRestCapacityMethod · 0.80
SetWriteSizeMethod · 0.80
CanReadOneProtocolMethod · 0.80
FitCapacityMethod · 0.80
ReadOneProtocolMethod · 0.80
RunFunction · 0.50
read_someMethod · 0.45
ParseMethod · 0.45
ResetMethod · 0.45

Tested by

no test coverage detected