diff --git a/LinuxLocalServer.cpp b/LinuxLocalServer.cpp index 3bbb902..471d339 100644 --- a/LinuxLocalServer.cpp +++ b/LinuxLocalServer.cpp @@ -6,9 +6,10 @@ using namespace OTF; LinuxLocalServer::LinuxLocalServer(uint16_t port) : server(port) {} LinuxLocalServer::~LinuxLocalServer() { - if (activeClient != nullptr) + if (activeClient != nullptr) { activeClient->stop(); delete activeClient; + } } @@ -72,4 +73,4 @@ void LinuxLocalClient::flush() { void LinuxLocalClient::stop() { client.stop(); } -#endif \ No newline at end of file +#endif diff --git a/LinuxLocalServer.h b/LinuxLocalServer.h index 1756cf4..34a99aa 100644 --- a/LinuxLocalServer.h +++ b/LinuxLocalServer.h @@ -14,6 +14,7 @@ namespace OTF { LinuxLocalClient(EthernetClient client); public: + virtual ~LinuxLocalClient() {} bool dataAvailable(); size_t readBytes(char *buffer, size_t length); size_t readBytesUntil(char terminator, char *buffer, size_t length); @@ -33,7 +34,7 @@ namespace OTF { public: LinuxLocalServer(uint16_t port); - ~LinuxLocalServer(); + virtual ~LinuxLocalServer(); LocalClient *acceptClient(); void begin(); @@ -41,4 +42,4 @@ namespace OTF { }// namespace OTF #endif -#endif \ No newline at end of file +#endif diff --git a/LocalServer.h b/LocalServer.h index 9bee9ec..c6bdb0e 100644 --- a/LocalServer.h +++ b/LocalServer.h @@ -12,6 +12,7 @@ namespace OTF { class LocalClient { public: + virtual ~LocalClient() {}; /** Returns a boolean indicating if data is currently available from this client. */ virtual bool dataAvailable() = 0; @@ -50,6 +51,7 @@ namespace OTF { class LocalServer { public: + virtual ~LocalServer() {}; /** * Closes the active client (if one is active) and accepts a new client (if one is available). * @return The newly accepted client, or `nullptr` if none was available. diff --git a/OpenThingsFramework.cpp b/OpenThingsFramework.cpp index 0e3f95a..b9cc53f 100755 --- a/OpenThingsFramework.cpp +++ b/OpenThingsFramework.cpp @@ -11,7 +11,7 @@ using namespace OTF; -OpenThingsFramework::OpenThingsFramework(uint16_t webServerPort, char *hdBuffer, int hdBufferSize) : localServer(webServerPort) { +OpenThingsFramework::OpenThingsFramework(uint16_t webServerPort, char *hdBuffer, size_t hdBufferSize) : localServer(webServerPort) { OTF_DEBUG("Instantiating OTF...\n"); if(hdBuffer != NULL) { // if header buffer is externally provided, use it directly headerBuffer = hdBuffer; @@ -26,10 +26,10 @@ OpenThingsFramework::OpenThingsFramework(uint16_t webServerPort, char *hdBuffer, #if defined(ARDUINO) OpenThingsFramework::OpenThingsFramework(uint16_t webServerPort, const String &webSocketHost, uint16_t webSocketPort, - const String &deviceKey, bool useSsl, char *hdBuffer, int hdBufferSize) : OpenThingsFramework(webServerPort, hdBuffer, hdBufferSize) { + const String &deviceKey, bool useSsl, char *hdBuffer, size_t hdBufferSize) : OpenThingsFramework(webServerPort, hdBuffer, hdBufferSize) { #else OpenThingsFramework::OpenThingsFramework(uint16_t webServerPort, const char* webSocketHost, uint16_t webSocketPort, - const char* deviceKey, bool useSsl, char *hdBuffer, int hdBufferSize) : OpenThingsFramework(webServerPort, hdBuffer, hdBufferSize) { + const char* deviceKey, bool useSsl, char *hdBuffer, size_t hdBufferSize) : OpenThingsFramework(webServerPort, hdBuffer, hdBufferSize) { #endif setCloudStatus(UNABLE_TO_CONNECT); OTF_DEBUG(F("Initializing websocket...\n")); diff --git a/OpenThingsFramework.h b/OpenThingsFramework.h index cc338a3..8da32b2 100644 --- a/OpenThingsFramework.h +++ b/OpenThingsFramework.h @@ -63,7 +63,7 @@ namespace OTF { CLOUD_STATUS cloudStatus = NOT_ENABLED; unsigned long lastCloudStatusChangeTime = millis(); char *headerBuffer = NULL; - int headerBufferSize = 0; + size_t headerBufferSize = 0; void webSocketEventCallback(WSEvent_t type, uint8_t *payload, size_t length); @@ -80,7 +80,7 @@ namespace OTF { * @param hdBuffer externally provided header buffer (optional) * @param hdBufferSize size of the externally provided header buffer (optional) */ - OpenThingsFramework(uint16_t webServerPort, char *hdBuffer = NULL, int hdBufferSize = HEADERS_BUFFER_SIZE); + OpenThingsFramework(uint16_t webServerPort, char *hdBuffer = NULL, size_t hdBufferSize = HEADERS_BUFFER_SIZE); /** * Initializes the library to listen on a local webserver and connect to a remote websocket. @@ -94,10 +94,10 @@ namespace OTF { */ #if defined(ARDUINO) OpenThingsFramework(uint16_t webServerPort, const String &webSocketHost, uint16_t webSocketPort, - const String &deviceKey, bool useSsl, char *hdBuffer = NULL, int hdBufferSize = HEADERS_BUFFER_SIZE); + const String &deviceKey, bool useSsl, char *hdBuffer = NULL, size_t hdBufferSize = HEADERS_BUFFER_SIZE); #else OpenThingsFramework(uint16_t webServerPort, const char *webSocketHost, uint16_t webSocketPort, - const char *deviceKey, bool useSsl, char *hdBuffer = NULL, int hdBufferSize = HEADERS_BUFFER_SIZE); + const char *deviceKey, bool useSsl, char *hdBuffer = NULL, size_t hdBufferSize = HEADERS_BUFFER_SIZE); #endif /** diff --git a/etherport.h b/etherport.h index 444d188..f8a2e65 100644 --- a/etherport.h +++ b/etherport.h @@ -49,7 +49,7 @@ class EthernetClient { public: EthernetClient(); EthernetClient(int sock); - ~EthernetClient(); + virtual ~EthernetClient(); virtual int connect(const char *server, uint16_t port); virtual bool connected(); virtual void stop(); @@ -77,7 +77,7 @@ class EthernetClientSsl : public EthernetClient { public: EthernetClientSsl(); EthernetClientSsl(int sock); - ~EthernetClientSsl(); + virtual ~EthernetClientSsl(); virtual int connect(const char *server, uint16_t port); virtual bool connected(); virtual void stop(); @@ -101,4 +101,4 @@ class EthernetServer { }; #endif -#endif /* _ETHERPORT_H_ */ \ No newline at end of file +#endif /* _ETHERPORT_H_ */