Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactoring websocket client and server. #1514

Merged
merged 5 commits into from
Nov 7, 2018
Merged
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
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.

7 changes: 7 additions & 0 deletions Sming/SmingCore/Network/Http/HttpConnection.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@
#include "../Services/DateTime/DateTime.h"
#include "Data/ObjectQueue.h"

/** @defgroup HTTP client connection
* @brief Provides http client connection
* @ingroup http
* @{
*/

typedef ObjectQueue<HttpRequest, HTTP_REQUEST_POOL_SIZE> RequestQueue;

class HttpConnection : public HttpConnectionBase
Expand Down Expand Up @@ -140,4 +146,5 @@ class HttpConnection : public HttpConnectionBase
HttpResponse response;
};

/** @} */
#endif /* _SMING_CORE_NETWORK_HTTP_CONNECTION_H_ */
11 changes: 11 additions & 0 deletions Sming/SmingCore/Network/Http/HttpConnectionBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@
#include "HttpResponse.h"
#include "HttpRequest.h"

/** @defgroup HTTP base connection
* @brief Provides http base used for client and server connections
* @ingroup http
* @{
*/

class HttpConnectionBase : public TcpClient
{
public:
Expand All @@ -36,6 +42,10 @@ class HttpConnectionBase : public TcpClient
protected:
void resetHeaders();

/**
* @brief Initializes the http parser for a specific type of HTTP message
* @param http_parser_type
*/
virtual void init(http_parser_type type);

// HTTP parser methods
Expand Down Expand Up @@ -139,4 +149,5 @@ class HttpConnectionBase : public TcpClient
HttpConnectionState state = eHCS_Ready;
};

/** @} */
#endif /* _SMING_CORE_NETWORK_HTTP_HTTPCONNECTIONBASE_H_ */
9 changes: 8 additions & 1 deletion Sming/SmingCore/Network/Http/HttpServerConnection.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@

#include <functional>

/** @defgroup HTTP server connection
* @brief Provides http server connection
* @ingroup http
* @{
*/

#ifndef HTTP_SERVER_EXPOSE_NAME
#define HTTP_SERVER_EXPOSE_NAME 1
#endif
Expand Down Expand Up @@ -46,7 +52,7 @@ class HttpServerConnection : public HttpConnectionBase

using TcpClient::send;

void setUpgdareCallback(HttpServerProtocolUpgradeCallback callback)
void setUpgradeCallback(HttpServerProtocolUpgradeCallback callback)
{
upgradeCallback = callback;
}
Expand Down Expand Up @@ -120,4 +126,5 @@ class HttpServerConnection : public HttpConnectionBase
HttpBodyParserDelegate bodyParser = 0;
};

/** @} */
#endif /* _SMING_CORE_NETWORK_HTTP_HTTPSERVERCONNECTION_H_ */
Loading