MCPcopy Create free account
hub / github.com/comaps/comaps / Reconnect

Method Reconnect

libs/tracking/connection.cpp:29–51  ·  view source on GitHub ↗

TODO: implement handshake

Source from the content-addressed store, hash-verified

27
28// TODO: implement handshake
29bool Connection::Reconnect()
30{
31 if (!m_socket)
32 return false;
33
34 m_socket->Close();
35
36 if (!m_socket->Open(m_host, m_port))
37 return false;
38
39 // TODO: generate unique client id here.
40 std::string clientId = "TODO";
41 auto packet = Protocol::CreateAuthPacket(clientId);
42 if (!m_socket->Write(packet.data(), static_cast<uint32_t>(packet.size())))
43 return false;
44
45 std::string check(std::begin(Protocol::kFail), std::end(Protocol::kFail));
46 bool const isSuccess = m_socket->Read(reinterpret_cast<uint8_t *>(&check[0]), static_cast<uint32_t>(check.size()));
47 if (!isSuccess || check != std::string(std::begin(Protocol::kOk), std::end(Protocol::kOk)))
48 return false;
49
50 return true;
51}
52
53void Connection::Shutdown()
54{

Callers 1

SendPointsMethod · 0.80

Calls 8

beginFunction · 0.50
endFunction · 0.50
CloseMethod · 0.45
OpenMethod · 0.45
WriteMethod · 0.45
dataMethod · 0.45
sizeMethod · 0.45
ReadMethod · 0.45

Tested by

no test coverage detected