summaryrefslogblamecommitdiffstats
path: root/src/server/net/discoverylistener.h
blob: 64d43515d7feb023968f3a9c044286c1c9669aec (plain) (tree)







































                                                                                                           
/*
 * 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_ */