OpenTTD Source 20241224-master-gf74b0cf984
|
Socket handler for the survey connection. More...
#include <network_survey.h>
Public Types | |
enum class | Reason { PREVIEW , LEAVE , EXIT , CRASH } |
Public Member Functions | |
void | Transmit (Reason reason, bool blocking=false) |
Transmit the survey. | |
std::string | CreatePayload (Reason reason, bool for_preview=false) |
Public Member Functions inherited from HTTPCallback | |
virtual | ~HTTPCallback ()=default |
Silentium. | |
Static Public Member Functions | |
static constexpr bool | IsSurveyPossible () |
Protected Member Functions | |
void | OnFailure () override |
An error has occurred and the connection has been closed. | |
void | OnReceiveData (std::unique_ptr< char[]> data, size_t length) override |
We're receiving data. | |
bool | IsCancelled () const override |
Check if there is a request to cancel the transfer. | |
Private Attributes | |
std::mutex | mutex |
Mutex for the condition variable. | |
std::atomic< bool > | transmitted |
Whether the survey has been transmitted. | |
std::condition_variable | transmitted_cv |
Condition variable to inform changes to transmitted. | |
Socket handler for the survey connection.
Definition at line 20 of file network_survey.h.
|
strong |
Enumerator | |
---|---|
PREVIEW | User is previewing the survey result. |
LEAVE | User is leaving the game (but not exiting the application). |
EXIT | User is exiting the application. |
CRASH | Game crashed. |
Definition at line 27 of file network_survey.h.
|
inlineoverrideprotectedvirtual |
Check if there is a request to cancel the transfer.
Implements HTTPCallback.
Definition at line 24 of file network_survey.h.
|
inlinestaticconstexpr |
Definition at line 37 of file network_survey.h.
|
overrideprotectedvirtual |
An error has occurred and the connection has been closed.
Implements HTTPCallback.
Definition at line 114 of file network_survey.cpp.
References Debug, transmitted, and transmitted_cv.
|
overrideprotectedvirtual |
We're receiving data.
data | the received data, nullptr when all data has been received. |
length | the amount of received data, 0 when all data has been received. |
Implements HTTPCallback.
Definition at line 121 of file network_survey.cpp.
References Debug, transmitted, and transmitted_cv.
void NetworkSurveyHandler::Transmit | ( | Reason | reason, |
bool | blocking = false |
||
) |
Transmit the survey.
reason | The reason for sending the survey. |
blocking | Whether to block until the survey is sent. |
Definition at line 86 of file network_survey.cpp.
References _settings_client, NetworkHTTPSocketHandler::Connect(), Debug, lock, mutex, ClientSettings::network, NetworkBackgroundLoop(), NetworkSurveyUriString(), NetworkSettings::participate_survey, transmitted, and transmitted_cv.
Referenced by CrashLog::SendSurvey().
|
private |
Mutex for the condition variable.
Definition at line 43 of file network_survey.h.
Referenced by Transmit().
|
private |
Whether the survey has been transmitted.
Definition at line 44 of file network_survey.h.
Referenced by OnFailure(), OnReceiveData(), and Transmit().
|
private |
Condition variable to inform changes to transmitted.
Definition at line 45 of file network_survey.h.
Referenced by OnFailure(), OnReceiveData(), and Transmit().