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

Method SendReceive

src/network/network_content.cpp:761–779  ·  view source on GitHub ↗

* Check whether we received/can send some data from/to the content server and * when that's the case handle it appropriately */

Source from the content-addressed store, hash-verified

759 * when that's the case handle it appropriately
760 */
761void ClientNetworkContentSocketHandler::SendReceive()
762{
763 if (this->sock == INVALID_SOCKET || this->is_connecting) return;
764
765 /* Close the connection to the content server after inactivity; there can still be downloads pending via HTTP. */
766 if (std::chrono::steady_clock::now() > this->last_activity + IDLE_TIMEOUT) {
767 this->CloseConnection();
768 return;
769 }
770
771 if (this->CanSendReceive()) {
772 if (this->ReceivePackets()) {
773 /* Only update activity once a packet is received, instead of every time we try it. */
774 this->last_activity = std::chrono::steady_clock::now();
775 }
776 }
777
778 this->SendPackets();
779}
780
781/** Timeout after queueing content for it to try to be requested. */
782static constexpr auto CONTENT_QUEUE_TIMEOUT = std::chrono::milliseconds(100);

Callers

nothing calls this directly

Calls 5

CloseConnectionMethod · 0.95
nowClass · 0.85
CanSendReceiveMethod · 0.80
SendPacketsMethod · 0.80
ReceivePacketsMethod · 0.45

Tested by

no test coverage detected