MqttBroker::server is now a unique_ptr

This commit is contained in:
hsaturn
2023-01-02 00:15:14 +01:00
parent b8022f58a4
commit d517cf2627
2 changed files with 4 additions and 4 deletions

View File

@@ -17,7 +17,7 @@ int TinyMqtt::debug=2;
MqttBroker::MqttBroker(uint16_t port)
{
server = new TcpServer(port);
server.reset(new TcpServer(port));
#ifdef TINY_MQTT_ASYNC
server->onClient(onClient, this);
#endif
@@ -29,7 +29,6 @@ MqttBroker::~MqttBroker()
{
delete clients[0];
}
delete server;
}
// private constructor used by broker only
@@ -165,6 +164,7 @@ void MqttBroker::onClient(void* broker_ptr, TcpClient* client)
void MqttBroker::loop()
{
#ifndef TINY_MQTT_ASYNC
if (not server) return;
WiFiClient client = server->available();
if (client)