* Check whether we received/can send some data from/to the content server and * when that's the case handle it appropriately */
| 759 | * when that's the case handle it appropriately |
| 760 | */ |
| 761 | void 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. */ |
| 782 | static constexpr auto CONTENT_QUEUE_TIMEOUT = std::chrono::milliseconds(100); |
nothing calls this directly
no test coverage detected