Merge branch 'yuboxfixes' into yuboxfixes-0xFEEDC0DE64-cleanup

This commit is contained in:
Alex Villacís Lasso
2021-02-25 18:39:39 -05:00

View File

@@ -137,16 +137,17 @@ size_t AsyncEventSourceMessage::ack(size_t len, uint32_t time) {
return 0; return 0;
} }
// This could also return void as the return value is not used.
// Leaving as-is for compatibility...
size_t AsyncEventSourceMessage::send(AsyncClient *client) { size_t AsyncEventSourceMessage::send(AsyncClient *client) {
const size_t len = _len - _sent; if (_sent >= _len) {
if(client->space() < len){ return 0;
return 0; }
} const size_t len_to_send = _len - _sent;
size_t sent = client->add((const char *)_data, len); auto position = reinterpret_cast<const char*>(_data + _sent);
if(client->canSend()) const size_t sent_now = client->write(position, len_to_send);
client->send(); _sent += sent_now;
_sent += sent; return sent_now;
return sent;
} }
// Client // Client