MCPcopy Create free account
hub / github.com/OpenLoco/OpenLoco / connect

Method connect

src/OpenLoco/src/Network/NetworkClient.cpp:31–51  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

29}
30
31void NetworkClient::connect(std::string_view host, port_t port)
32{
33 auto szHost = std::string(host);
34 _serverEndpoint = Socket::resolve(Protocol::any, szHost, port);
35
36 _sockets.push_back(Socket::createUdp());
37 auto& socket = _sockets.back();
38 _serverConnection = std::make_unique<NetworkConnection>(socket.get(), _serverEndpoint->clone());
39
40 auto szHostIpAddress = _serverEndpoint->getIpAddress();
41 Logging::info("Resolved endpoint for {}:{}", szHostIpAddress, port);
42
43 beginReceivePacketLoop();
44
45 _status = NetworkClientStatus::connecting;
46 _timeout = Platform::getTime() + 5000;
47
48 sendConnectPacket();
49
50 initStatus("Connecting to " + szHost + "...");
51}
52
53void NetworkClient::onClose()
54{

Callers 1

joinServerFunction · 0.80

Calls 8

resolveFunction · 0.85
createUdpFunction · 0.85
infoFunction · 0.85
push_backMethod · 0.80
getTimeFunction · 0.50
getMethod · 0.45
cloneMethod · 0.45
getIpAddressMethod · 0.45

Tested by

no test coverage detected