Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions LinuxLocalServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}


Expand Down Expand Up @@ -72,4 +73,4 @@ void LinuxLocalClient::flush() {
void LinuxLocalClient::stop() {
client.stop();
}
#endif
#endif
5 changes: 3 additions & 2 deletions LinuxLocalServer.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -33,12 +34,12 @@ namespace OTF {

public:
LinuxLocalServer(uint16_t port);
~LinuxLocalServer();
virtual ~LinuxLocalServer();

LocalClient *acceptClient();
void begin();
};
}// namespace OTF

#endif
#endif
#endif
2 changes: 2 additions & 0 deletions LocalServer.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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.
Expand Down
6 changes: 3 additions & 3 deletions OpenThingsFramework.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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"));
Expand Down
8 changes: 4 additions & 4 deletions OpenThingsFramework.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -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.
Expand All @@ -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

/**
Expand Down
6 changes: 3 additions & 3 deletions etherport.h
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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();
Expand All @@ -101,4 +101,4 @@ class EthernetServer {
};
#endif

#endif /* _ETHERPORT_H_ */
#endif /* _ETHERPORT_H_ */