| 95 | } |
| 96 | |
| 97 | int NativeHttpServer::send(u32 clientId, fl::span<const u8> data) { |
| 98 | ServerClientConnection* client = findClient(clientId); |
| 99 | if (!client || !client->socket.is_open()) { |
| 100 | return -1; |
| 101 | } |
| 102 | |
| 103 | asio::error_code ec; |
| 104 | size_t n = client->socket.write_some(data, ec); |
| 105 | |
| 106 | if (ec) { |
| 107 | if (ec.code == asio::errc::would_block) { |
| 108 | return 0; |
| 109 | } |
| 110 | // Connection error, disconnect client |
| 111 | client->connection.onDisconnected(); |
| 112 | return -1; |
| 113 | } |
| 114 | |
| 115 | return static_cast<int>(n); |
| 116 | } |
| 117 | |
| 118 | int NativeHttpServer::recv(u32 clientId, fl::span<u8> buffer) { |
| 119 | ServerClientConnection* client = findClient(clientId); |
nothing calls this directly
no test coverage detected