Skip to content

Commit

Permalink
Initial refactoring of the WebsocketClient.
Browse files Browse the repository at this point in the history
Renamed the method making the `binding` to a http server socket to be called `bind`.

Fix for potential memory leak + Codacy fixes.

Reapplied coding-standards.

Small changes.

Updated the example to update every 20 seconds instead of 60.
Better init and deinit of streams

Added timeouts to keep the connection for longer periods.

Reset the HttpConnection timeout on a new connect.

- Don't send new HTTP request over the same TCP connection if is already started.
- Make HttpConnection::reset to be extendable. This allows also the WebsocketClient to reset the connection.

Use SSL by default

Refactored the HttpClient and Connection to reuse code.
Refactored the WebsocketConnection to be reused in server and client mode.
  • Loading branch information
slav-at-attachix committed Nov 5, 2018
1 parent 5ce92d1 commit fdfca22
Show file tree
Hide file tree
Showing 25 changed files with 744 additions and 1,444 deletions.
2 changes: 1 addition & 1 deletion Sming/Services/CommandProcessing/CommandExecutor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ CommandExecutor::CommandExecutor(Stream* reqStream) : CommandExecutor()
}
}

CommandExecutor::CommandExecutor(WebSocketConnection* reqSocket)
CommandExecutor::CommandExecutor(WebsocketConnection* reqSocket)
{
commandOutput = new CommandOutput(reqSocket);
if (commandHandler.getVerboseMode() != SILENT)
Expand Down
2 changes: 1 addition & 1 deletion Sming/Services/CommandProcessing/CommandExecutor.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class CommandExecutor
public:
CommandExecutor(TcpClient* cmdClient);
CommandExecutor(Stream* reqStream);
CommandExecutor(WebSocketConnection* reqSocket);
CommandExecutor(WebsocketConnection* reqSocket);
~CommandExecutor();

int executorReceive(char *recvData, int recvSize);
Expand Down
2 changes: 1 addition & 1 deletion Sming/Services/CommandProcessing/CommandOutput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ CommandOutput::CommandOutput(Stream* reqStream)
{
}

CommandOutput::CommandOutput(WebSocketConnection* reqSocket)
CommandOutput::CommandOutput(WebsocketConnection* reqSocket)
: outputSocket(reqSocket)
{
}
Expand Down
6 changes: 3 additions & 3 deletions Sming/Services/CommandProcessing/CommandOutput.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,21 @@
#include "Stream.h"
#include "Print.h"
#include "WiringFrameworkDependencies.h"
#include "Network/Http/Websocket/WebSocketConnection.h"
#include "Network/Http/Websocket/WebsocketConnection.h"

class CommandOutput: public Print
{
public:
CommandOutput(TcpClient* reqClient);
CommandOutput(Stream* reqStream);
CommandOutput(WebSocketConnection* reqSocket);
CommandOutput(WebsocketConnection* reqSocket);
virtual ~CommandOutput();

size_t write(uint8_t outChar);

TcpClient* outputTcpClient = nullptr;
Stream* outputStream = nullptr;
WebSocketConnection* outputSocket = nullptr;
WebsocketConnection* outputSocket = nullptr;
String tempSocket = "";
};

Expand Down
145 changes: 0 additions & 145 deletions Sming/Services/cWebsocket/websocket.cpp

This file was deleted.

105 changes: 0 additions & 105 deletions Sming/Services/cWebsocket/websocket.h

This file was deleted.

Loading

0 comments on commit fdfca22

Please sign in to comment.