summaryrefslogblamecommitdiffstats
path: root/src/server/net/discoverylistener.h
blob: 47a42953889d61d67120f92a87e4e8041b84c9ba (plain) (tree)
1
2
3
4
5
6
7
8
9
10









                            
                  




                                        

                  






                                        
                               
 
                                                                                                             

          
                                                     

       

                                                    






                                 
/*
 * discoverylistener.h
 *
 *  Created on: 25.01.2013
 *      Author: sr
 */

#ifndef DISCOVERYLISTENER_H_
#define DISCOVERYLISTENER_H_

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

#define SD_PACKET_TABLE_SIZE 20000

class QTimerEvent;

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) override;

public:
	explicit DiscoveryListener(QObject *parent);
	~DiscoveryListener() override;

private slots:
	void onReadyRead();

};

#endif /* DISCOVERYLISTENER_H_ */