QTfrontend/netudpwidget.cpp
changeset 5146 7b65e83e261d
parent 4976 088d40d8aba2
child 5147 a2ae7702bb75
equal deleted inserted replaced
5145:120f4271f197 5146:7b65e83e261d
    35     games.clear();
    35     games.clear();
    36 
    36 
    37     reset();
    37     reset();
    38 
    38 
    39     pUdpSocket->writeDatagram("hedgewars client", QHostAddress::Broadcast, 46631);
    39     pUdpSocket->writeDatagram("hedgewars client", QHostAddress::Broadcast, 46631);
       
    40     pUdpSocket->writeDatagram("hedgewars client", QHostAddress("127.0.0.1"), 46631);
    40 }
    41 }
    41 
    42 
    42 void HWNetUdpModel::onClientRead()
    43 void HWNetUdpModel::onClientRead()
    43 {
    44 {
    44     while (pUdpSocket->hasPendingDatagrams()) {
    45     while (pUdpSocket->hasPendingDatagrams()) {
    47         QHostAddress clientAddr;
    48         QHostAddress clientAddr;
    48         quint16 clientPort;
    49         quint16 clientPort;
    49 
    50 
    50         pUdpSocket->readDatagram(datagram.data(), datagram.size(), &clientAddr, &clientPort);
    51         pUdpSocket->readDatagram(datagram.data(), datagram.size(), &clientAddr, &clientPort);
    51 
    52 
    52         if(QString("%1").arg(datagram.data())==QString("hedgewars server")) {
    53         QString packet = QString::fromUtf8(datagram.data());
       
    54         if(packet.startsWith("hedgewars server")) {
    53             QStringList sl;
    55             QStringList sl;
    54             sl << "-" << clientAddr.toString() << "46631";
    56             sl << packet.remove(0, 17) << clientAddr.toString() << "46631";
    55             games.append(sl);
    57             games.append(sl);
    56         }
    58         }
    57     }
    59     }
    58 
    60 
    59     reset();
    61     reset();