QTfrontend/net/netudpserver.cpp
changeset 6616 f77bb02b669f
parent 6060 fdfc01419815
child 6700 e04da46ee43c
--- a/QTfrontend/net/netudpserver.cpp	Mon Jan 30 23:20:28 2012 +0100
+++ b/QTfrontend/net/netudpserver.cpp	Mon Jan 30 17:32:18 2012 -0500
@@ -22,30 +22,32 @@
 #include "netudpserver.h"
 
 HWNetUdpServer::HWNetUdpServer(QObject *parent, const QString & descr, quint16 port) :
-  HWNetRegisterServer(parent, descr, port),
-  m_descr(descr)
+    HWNetRegisterServer(parent, descr, port),
+    m_descr(descr)
 {
-  pUdpSocket = new QUdpSocket(this);
-  pUdpSocket->bind(46631);
-  connect(pUdpSocket, SIGNAL(readyRead()), this, SLOT(onClientRead()));
+    pUdpSocket = new QUdpSocket(this);
+    pUdpSocket->bind(46631);
+    connect(pUdpSocket, SIGNAL(readyRead()), this, SLOT(onClientRead()));
 }
 
 void HWNetUdpServer::onClientRead()
 {
-  while (pUdpSocket->hasPendingDatagrams()) {
-    QByteArray datagram;
-    datagram.resize(pUdpSocket->pendingDatagramSize());
-    QHostAddress clientAddr;
-    quint16 clientPort;
-    pUdpSocket->readDatagram(datagram.data(), datagram.size(), &clientAddr, &clientPort);
-    if(datagram.startsWith("hedgewars client")) {
-      // send answer to client
-      pUdpSocket->writeDatagram(QString("hedgewars server\n%1").arg(m_descr).toUtf8(), clientAddr, clientPort);
+    while (pUdpSocket->hasPendingDatagrams())
+    {
+        QByteArray datagram;
+        datagram.resize(pUdpSocket->pendingDatagramSize());
+        QHostAddress clientAddr;
+        quint16 clientPort;
+        pUdpSocket->readDatagram(datagram.data(), datagram.size(), &clientAddr, &clientPort);
+        if(datagram.startsWith("hedgewars client"))
+        {
+            // send answer to client
+            pUdpSocket->writeDatagram(QString("hedgewars server\n%1").arg(m_descr).toUtf8(), clientAddr, clientPort);
+        }
     }
-  }
 }
 
 void HWNetUdpServer::unregister()
 {
-  deleteLater();
+    deleteLater();
 }