Skip to content

Commit

Permalink
Detect if AsyncWebSocketClient can send data to server and add AsyncW…
Browse files Browse the repository at this point in the history
…ebServer::end() (homieiot#501)

* added AsyncWebServer::end()

* added AsyncWebServer::end()

* added bool AsyncWebSocketClient::canSend()

* Fix comparison with WS_MAX_QUEUED_MESSAGES

* Fix comparison with WS_MAX_QUEUED_MESSAGES
  • Loading branch information
dyarkovoy authored and me-no-dev committed Jun 22, 2019
1 parent 6dcea3f commit 5ef7ffc
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/AsyncWebSocket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -551,7 +551,7 @@ void AsyncWebSocketClient::_queueMessage(AsyncWebSocketMessage *dataMessage){
delete dataMessage;
return;
}
if(_messageQueue.length() > WS_MAX_QUEUED_MESSAGES){
if(_messageQueue.length() >= WS_MAX_QUEUED_MESSAGES){
ets_printf("ERROR: Too many messages queued\n");
delete dataMessage;
} else {
Expand Down
2 changes: 2 additions & 0 deletions src/AsyncWebSocket.h
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,8 @@ class AsyncWebSocketClient {
void binary(const __FlashStringHelper *data, size_t len);
void binary(AsyncWebSocketMessageBuffer *buffer);

bool canSend() { return _messageQueue.length() < WS_MAX_QUEUED_MESSAGES; }

//system callbacks (do not call)
void _onAck(size_t len, uint32_t time);
void _onError(int8_t);
Expand Down

0 comments on commit 5ef7ffc

Please sign in to comment.