MCPcopy Create free account
hub / github.com/OpenTTD/OpenTTD / Transmit

Method Transmit

src/network/network_survey.cpp:86–112  ·  view source on GitHub ↗

* Transmit the survey. * * @param reason The reason for sending the survey. * @param blocking Whether to block until the survey is sent. */

Source from the content-addressed store, hash-verified

84 * @param blocking Whether to block until the survey is sent.
85 */
86void NetworkSurveyHandler::Transmit(Reason reason, bool blocking)
87{
88 if constexpr (!NetworkSurveyHandler::IsSurveyPossible()) {
89 Debug(net, 4, "Survey: not possible to send survey; most likely due to missing JSON library at compile-time");
90 return;
91 }
92
93 if (_settings_client.network.participate_survey != PS_YES) {
94 Debug(net, 5, "Survey: user is not participating in survey; skipping survey");
95 return;
96 }
97
98 Debug(net, 1, "Survey: sending survey results");
99 NetworkHTTPSocketHandler::Connect(NetworkSurveyUriString(), this, this->CreatePayload(reason));
100
101 if (blocking) {
102 std::unique_lock<std::mutex> lock(this->mutex);
103
104 /* Block no longer than 2 seconds. If we failed to send the survey in that time, so be it. */
105 std::chrono::steady_clock::time_point end = std::chrono::steady_clock::now() + std::chrono::seconds(2);
106
107 while (!this->transmitted && std::chrono::steady_clock::now() < end) {
108 NetworkBackgroundLoop();
109 this->transmitted_cv.wait_for(lock, std::chrono::milliseconds(30));
110 }
111 }
112}
113
114void NetworkSurveyHandler::OnFailure()
115{

Callers 4

AskExitGameCallbackFunction · 0.80
HandleExitGameRequestFunction · 0.80
SwitchToModeFunction · 0.80
SendSurveyMethod · 0.80

Calls 4

CreatePayloadMethod · 0.95
NetworkSurveyUriStringFunction · 0.85
nowClass · 0.85
NetworkBackgroundLoopFunction · 0.85

Tested by

no test coverage detected