summaryrefslogtreecommitdiffstats
path: root/src/server/net/discoverylistener.h
blob: 64d43515d7feb023968f3a9c044286c1c9669aec (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
/*
 * discoverylistener.h
 *
 *  Created on: 25.01.2013
 *      Author: sr
 */

#ifndef DISCOVERYLISTENER_H_
#define DISCOVERYLISTENER_H_

#include <QtCore>
#include <QUdpSocket>
#include "../../shared/networkmessage.h"

#define SD_PACKET_TABLE_SIZE 20000

class DiscoveryListener : public QObject
{
	Q_OBJECT

private:
	QUdpSocket _socket;
	NetworkMessage _packet;
	int _counterResetPos;

	quint8 _packetCounter[SD_PACKET_TABLE_SIZE]; // count packets per source address to ignore spammers

protected:
	void timerEvent(QTimerEvent* event);

public:
	DiscoveryListener();
	virtual ~DiscoveryListener();

private slots:
	void onReadyRead();

};

#endif /* DISCOVERYLISTENER_H_ */