Listserver::Listserver(QObject *parent) : QObject(parent) { connect(this, SIGNAL(config(QString, QVariant)), this->parent(), SIGNAL(config(QString, QVariant))); connect(this, SIGNAL(log(QVariant)), this->parent(), SIGNAL(log(QVariant))); this->listserverSock = new QTcpSocket(this); this->timeout = config("listserver/timeout", 5).toInt(); this->reconnectDelay = config("listserver/reconnectDelay", 10).toInt(); this->listPort = config("listserver/port", 10054).toInt(); this->listservers = config("listserver/hosts", QString("list.jazzjackrabbit.com,list1.digiex.net,list2.digiex.net").split(",")).toStringList(); this->currentServer = 0; this->isListed = config("listserver/list", true).toBool(); this->instantReconnect = false; this->unexpectedDisconnect = true; connect(this->listserverSock, SIGNAL(connected()), this, SLOT(listConnected())); connect(this->listserverSock, SIGNAL(readyRead()), this, SLOT(listProcessPackets())); connect(this->listserverSock, SIGNAL(disconnected()), this, SLOT(listDisconnected())); connect(this->listserverSock, SIGNAL(stateChanged(QAbstractSocket::SocketState)), this, SLOT(listError())); this->timeoutTimer = new QTimer(this); this->timeoutTimer->setInterval(this->timeout*1000); this->timeoutTimer->setSingleShot(true); connect(this->timeoutTimer, SIGNAL(timeout()), this, SLOT(listTimeout())); this->reconnectTimer = new QTimer(this); this->reconnectTimer->setInterval(this->reconnectDelay*1000); this->reconnectTimer->setSingleShot(true); connect(this->reconnectTimer, SIGNAL(timeout()), this, SLOT(listReconnect())); // old code, keep for reference, will be useful sometime in the future /*PACKET_SERVERLIST_LIST packet; packet.port = 10052; packet.servername = "AAAAAA"; packet.flags.isPrivate = true; packet.flags.gametype = 3; QByteArray bytes; QDataStream stream(&bytes, QIODevice::ReadWrite); stream << packet.port; //bytes.append(packet.servername); //bytes.append(QByteArray(33-packet.servername.length(), 0)); // padding stream << packet.flags; qDebug() << bytes.toHex();*/ }
// ------------------------------------------------------------------------- // UartManagerCL::scanAndAlloc // ------------------------------------------------------------------------- void UartManagerCL::scanAndAlloc() { searchAndOpen(); allocDevices(); listConnected(); }