equal
deleted
inserted
replaced
18 */ |
18 */ |
19 |
19 |
20 #include <QUdpSocket> |
20 #include <QUdpSocket> |
21 |
21 |
22 #include "netudpwidget.h" |
22 #include "netudpwidget.h" |
|
23 #include "hwconsts.h" |
23 |
24 |
24 HWNetUdpModel::HWNetUdpModel(QObject* parent) : |
25 HWNetUdpModel::HWNetUdpModel(QObject* parent) : |
25 HWNetServersModel(parent) |
26 HWNetServersModel(parent) |
26 { |
27 { |
27 pUdpSocket = new QUdpSocket(this); |
28 pUdpSocket = new QUdpSocket(this); |
34 { |
35 { |
35 games.clear(); |
36 games.clear(); |
36 |
37 |
37 reset(); |
38 reset(); |
38 |
39 |
39 pUdpSocket->writeDatagram("hedgewars client", QHostAddress::Broadcast, 46631); |
40 pUdpSocket->writeDatagram("hedgewars client", QHostAddress::Broadcast, NETGAME_DEFAULT_PORT); |
40 } |
41 } |
41 |
42 |
42 void HWNetUdpModel::onClientRead() |
43 void HWNetUdpModel::onClientRead() |
43 { |
44 { |
44 while (pUdpSocket->hasPendingDatagrams()) |
45 while (pUdpSocket->hasPendingDatagrams()) |
52 |
53 |
53 QString packet = QString::fromUtf8(datagram.data()); |
54 QString packet = QString::fromUtf8(datagram.data()); |
54 if(packet.startsWith("hedgewars server")) |
55 if(packet.startsWith("hedgewars server")) |
55 { |
56 { |
56 QStringList sl; |
57 QStringList sl; |
57 sl << packet.remove(0, 17) << clientAddr.toString() << "46631"; |
58 sl << packet.remove(0, 17) << clientAddr.toString() << QString::number(NETGAME_DEFAULT_PORT); |
58 games.append(sl); |
59 games.append(sl); |
59 } |
60 } |
60 } |
61 } |
61 |
62 |
62 reset(); |
63 reset(); |