void ExtPlaneConnection::connectTo(QString host, unsigned int port) { close(); _host = host; _port = port; abort(); tryReconnect(); }
ExtPlaneConnection::ExtPlaneConnection(QObject *parent) : QTcpSocket(parent), updateInterval(0.333) { connect(this, SIGNAL(connected()), this, SLOT(socketConnected())); connect(this, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(socketError(QAbstractSocket::SocketError))); connect(this, SIGNAL(readyRead()), this, SLOT(readClient())); connect(&reconnectTimer, SIGNAL(timeout()), this, SLOT(tryReconnect())); server_ok = false; enableSimulatedRefs = false; }
void DgMqttHelper::setup(Client& client, const char* clientId, const char * domain, uint16_t port) { _mqttClient = client; _topicPrefix = clientId; _clientId = clientId; _mqttClient.setClient(client); _mqttClient.setServer(domain, port); Serial.print("mqttClient state: "); Serial.println(_mqttClient.state()); tryReconnect(); }
void DgMqttHelper::loop() { if (!_mqttClient.connected()) { tryReconnect(); } _mqttClient.loop(); }