Skip to content

Commit

Permalink
WebsocketConnection not getting destroyed
Browse files Browse the repository at this point in the history
HttpConnection is NOT auto-self-destruct so we need to change that during closure.
  • Loading branch information
mikee47 committed Mar 29, 2024
1 parent f9380db commit 6715ab2
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ void WebsocketConnection::broadcast(const char* message, size_t length, ws_frame

void WebsocketConnection::close()
{
debug_d("Terminating Websocket connection.");
debug_d("WS: Terminating connection %p", connection);
websocketList.removeElement(this);
if(state != eWSCS_Closed) {
state = eWSCS_Closed;
Expand All @@ -307,6 +307,7 @@ void WebsocketConnection::close()

if(connection) {
connection->setTimeOut(2);
connection->setAutoSelfDestruct(true);
connection = nullptr;
}
}
Expand Down
6 changes: 5 additions & 1 deletion Sming/Components/Network/src/Network/TcpConnection.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,15 @@ class TcpConnection : public IpConnection

virtual ~TcpConnection();

public:
virtual bool connect(const String& server, int port, bool useSsl = false);
virtual bool connect(IpAddress addr, uint16_t port, bool useSsl = false);
virtual void close();

void setAutoSelfDestruct(bool state)
{
autoSelfDestruct = state;
}

/** @brief Writes string data directly to the TCP buffer
* @param data null terminated string
* @param apiflags TCP_WRITE_FLAG_COPY, TCP_WRITE_FLAG_MORE
Expand Down

0 comments on commit 6715ab2

Please sign in to comment.