mirror of
https://github.com/me-no-dev/ESPAsyncWebServer.git
synced 2025-09-27 14:50:56 +02:00
Fix #888, AsyncEventSourceMessage::send()
Tested with 16 kB message size: Respect number of already sent bytes in successive calls to AsyncEventSourceMessage::send()
This commit is contained in:
@@ -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 * sizeof(*_data));
|
||||||
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
|
||||||
|
Reference in New Issue
Block a user