Skip to content

Commit

Permalink
Added method to access clients of AsyncWebSocket (#583)
Browse files Browse the repository at this point in the history
* Added method to access clients of AsyncWebSocket

* #571

* Conflict with crypto library
  • Loading branch information
sascha432 authored and me-no-dev committed Oct 2, 2019
1 parent 8451c0d commit 403752a
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
3 changes: 3 additions & 0 deletions src/AsyncWebSocket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1236,6 +1236,9 @@ void AsyncWebSocket::_cleanBuffers()
}
}

AsyncWebSocket::AsyncWebSocketClientLinkedList AsyncWebSocket::getClients() const {
return _clients;
}

/*
* Response to Web Socket request - sends the authorization and detaches the TCP Client from the web server
Expand Down
9 changes: 8 additions & 1 deletion src/AsyncWebSocket.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@

#ifdef ESP8266
#include <Hash.h>
#ifdef CRYPTO_HASH_h // include Hash.h from espressif framework if the first include was from the crypto library
#include <../src/Hash.h>
#endif
#endif

#ifdef ESP32
Expand Down Expand Up @@ -238,9 +241,11 @@ typedef std::function<void(AsyncWebSocket * server, AsyncWebSocketClient * clien

//WebServer Handler implementation that plays the role of a socket server
class AsyncWebSocket: public AsyncWebHandler {
public:
typedef LinkedList<AsyncWebSocketClient *> AsyncWebSocketClientLinkedList;
private:
String _url;
LinkedList<AsyncWebSocketClient *> _clients;
AsyncWebSocketClientLinkedList _clients;
uint32_t _cNextId;
AwsEventHandler _eventHandler;
bool _enabled;
Expand Down Expand Up @@ -325,6 +330,8 @@ class AsyncWebSocket: public AsyncWebHandler {
AsyncWebSocketMessageBuffer * makeBuffer(uint8_t * data, size_t size);
LinkedList<AsyncWebSocketMessageBuffer *> _buffers;
void _cleanBuffers();

AsyncWebSocketClientLinkedList getClients() const;
};

//WebServer response to authenticate the socket and detach the tcp client from the web server request
Expand Down
1 change: 1 addition & 0 deletions src/WebResponses.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -446,6 +446,7 @@ size_t AsyncAbstractResponse::_fillBufferAndProcessTemplates(uint8_t* data, size
_cache.insert(_cache.begin(), &data[originalLen - (pTemplateStart + numBytesCopied - pTemplateEnd - 1)], &data[len]);
//2. parameter value is longer than placeholder text, push the data after placeholder which not saved into cache further to the end
memmove(pTemplateStart + numBytesCopied, pTemplateEnd + 1, &data[originalLen] - pTemplateStart - numBytesCopied);
len = originalLen; // fix issue with truncated data, not sure if it has any side effects
} else if(pTemplateEnd + 1 != pTemplateStart + numBytesCopied)
//2. Either parameter value is shorter than placeholder text OR there is enough free space in buffer to fit.
// Move the entire data after the placeholder
Expand Down

0 comments on commit 403752a

Please sign in to comment.