| 116 | } |
| 117 | |
| 118 | int NativeHttpServer::recv(u32 clientId, fl::span<u8> buffer) { |
| 119 | ServerClientConnection* client = findClient(clientId); |
| 120 | if (!client || !client->socket.is_open()) { |
| 121 | return -1; |
| 122 | } |
| 123 | |
| 124 | asio::error_code ec; |
| 125 | size_t n = client->socket.read_some(buffer, ec); |
| 126 | |
| 127 | if (ec) { |
| 128 | if (ec.code == asio::errc::would_block) { |
| 129 | return 0; // Non-blocking socket, no data available |
| 130 | } |
| 131 | // Connection error or EOF, disconnect client |
| 132 | client->connection.onDisconnected(); |
| 133 | return -1; |
| 134 | } |
| 135 | |
| 136 | // Data received, update heartbeat tracking |
| 137 | client->connection.onHeartbeatReceived(); |
| 138 | |
| 139 | return static_cast<int>(n); |
| 140 | } |
| 141 | |
| 142 | void NativeHttpServer::broadcast(fl::span<const u8> data) { |
| 143 | // Send to all clients |
nothing calls this directly
no test coverage detected