Пример #1
0
void searchGameForm::init(){
    if(client == 0) this->reject();
    this->setWindowTitle("Идет поиск соперника");
    this->setMaximumHeight(heigthP);
    this->setMinimumHeight(heigthP);
    this->setMaximumWidth(widthP);
    this->setMinimumWidth(widthP);
    QVBoxLayout* main = new QVBoxLayout;
    this->setLayout(main);
    main->addWidget(new WaiterWidget());
    connect(client, SIGNAL(gameFound(quint8, QString)), this, SLOT(gameFound(quint8, QString)));
}
Пример #2
0
void BFScout::incomingData()
{
#define BUFFER_SIZE 1024

   char buffer[BUFFER_SIZE];
   qint64 read;

   read = mpSocket->readDatagram(buffer, BUFFER_SIZE);

   if (read > -1)
   {
      QString str = QString::fromLatin1(buffer, read);
      QStringList items = str.split(QChar('\n'), QString::SkipEmptyParts);
      QString name, address;
      int major, minor, port;

      if (items.count() == 5)
      {
         if (items[0] == "BlindFox announce")
         {
            QStringList ver = items[1].split(QChar('.'), QString::SkipEmptyParts);
            if (ver.count() == 2)
            {
               major = ver[0].toInt();
               minor = ver[1].toInt();

               if (major == 0 && minor == 1)
               {
                  name = items[2];
                  address = items[3];
                  port = items[4].toInt();

                  emit gameFound(name, address, port, major, minor);
               }
            }
         }
      }
   }

#undef BUFFER_SIZE
}