source: pacpussensors/trunk/PacpusSocket/PacpusSocketAirplug.h@ 132

Last change on this file since 132 was 85, checked in by phudelai, 10 years ago

socket corrected

File size: 2.4 KB
RevLine 
[85]1/*********************************************************************
2// created: 2012/03/01 - 14:06
3// filename: PacpusSocketAirplug.h
4//
5// author: Pierre Hudelaine
6// Copyright Heudiasyc UMR UTC/CNRS 7253
7//
8// version: $Id: $
9//
10// purpose: Create network socket if needed in Pacpus
11//
12*********************************************************************/
13
14#include <qudpsocket.h>
15
16#include "Pacpus/kernel/Log.h"
17#include "Pacpus/kernel/ComponentBase.h"
18#include "Pacpus/kernel/ComponentFactory.h"
19
20// Export macro for PacpusSocket DLL for Windows only
21#ifdef WIN32
22# ifdef PACPUSSOCKET_EXPORTS
23 // make DLL
24# define PACPUSSOCKET_API __declspec(dllexport)
25# else
26 // use DLL
27# define PACPUSSOCKET_API __declspec(dllimport)
28# endif
29#else
30 // On other platforms, simply ignore this
31# define PACPUSSOCKET_API
32#endif
33
34class QByteArray;
35
36namespace pacpus {
37
38class PACPUSSOCKET_API Client
39{
40public:
41 /// Constructor
42 Client();
43 Client(QHostAddress address, quint16 port) {address_ = address; port_ = port;};
44 /// Destructor
45 ~Client();
46
47 QHostAddress address_;
48 quint16 port_;
49
50 QHostAddress getAddress() {return address_;};
51 quint16 getPort() {return port_;};
52};
53
54class PACPUSSOCKET_API PacpusSocketAirplug
55 : public QObject
56 , public ComponentBase
57{
58 Q_OBJECT
59
60public:
61 /// Constructor
62 PacpusSocketAirplug(QString name);
63
64 /// Destructor
65 ~PacpusSocketAirplug();
66 PacpusSocketAirplug * getSocket() {return this;}
67
68public Q_SLOTS:
69 /// Slot de lecture des paquets envoys pour tests
70 void readPendingDatagrams();
71
72 /// Slot d'envoie des paquets
73 void sendDatagrams(QString frame);
74 void sendDatagrams(QByteArray frame);
75
76Q_SIGNALS:
77 void newDatagram(QByteArray datagram);
78 void newQString(QString string);
79
80protected:
81 // The 3 virtual methods relative to the ComponentBase inheritance
82 virtual void startActivity();
83 virtual void stopActivity();
84 virtual COMPONENT_CONFIGURATION configureComponent(XmlComponentConfig config);
85
86 QUdpSocket * udpSocket_;
87
88 quint16 port2bind_;
89 quint16 port2send_;
90 QHostAddress address2send_;
91 QString socketType_;
92
93 QList <Client *> listClients;
94};
95
96} // namespace pacpus
Note: See TracBrowser for help on using the repository browser.