Classified ads
networklistener.h
Go to the documentation of this file.
1 /* -*-C++-*- -*-coding: utf-8-unix;-*-
2  Classified Ads is Copyright (c) Antti Järvinen 2013.
3 
4  This file is part of Classified Ads.
5 
6  Classified Ads is free software: you can redistribute it and/or modify
7  it under the terms of the GNU General Public License as published by
8  the Free Software Foundation, either version 3 of the License, or
9  (at your option) any later version.
10 
11  Classified Ads is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  GNU General Public License for more details.
15 
16  You should have received a copy of the GNU General Public License
17  along with Classified Ads. If not, see <http://www.gnu.org/licenses/>.
18 */
19 
20 
21 
22 #ifndef NETWORK_LISTENER_H
23 #define NETWORK_LISTENER_H
24 
25 #include <QTcpServer>
26 #include <QList>
27 #include "connection.h" // for ConnectionObserver
28 #include <QUdpSocket>
29 
30 class MController ;
31 class Model ;
33 
41  public QTcpServer,
43  Q_OBJECT
44 public:
52  NetworkListener(MController *aController,
53  Model *aModel) ;
66  bool startListen(bool aIpv6) ;
67 
71  virtual bool dataReceived(const QByteArray& aData,
72  Connection& aConnection) ;
77  virtual void connectionClosed(Connection *aDeletee) ;
82  virtual void connectionReady(Connection *aBusinessEntity) ;
86  void stopAccepting() ;
87 protected:
88  void incomingConnection (int aSocketDescriptor ) ;
89 signals:
90  void error(QTcpSocket::SocketError socketError);
99  const Hash aHashOfAttemptedNode );
100 private slots:
101  void broadCastReceived() ;
102  void threadIsDeleted() ;
103 private: // methods
104  void figureOutLocalAddresses() ;
105 private: // data
110  QUdpSocket iBroadCastListener ;
115  bool iCanAccept ;
116 } ;
117 #endif
Class containing routines for parsing protocol messages. Methods are mainly called from network conne...
Definition: protocol_message_parser.h:39
void stopAccepting()
ProtocolMessageParser * iParser
Definition: networklistener.h:109
void threadIsDeleted()
virtual void connectionClosed(Connection *aDeletee)
virtual void connectionReady(Connection *aBusinessEntity)
void error(QTcpSocket::SocketError socketError)
QUdpSocket iBroadCastListener
Definition: networklistener.h:110
void nodeConnectionAttemptStatus(Connection::ConnectionState aStatus, const Hash aHashOfAttemptedNode)
Hash is class that carries 160-bit digest.
Definition: hash.h:37
MController * iController
Definition: networklistener.h:106
ConnectionState
Definition: connection.h:45
void broadCastReceived()
class for listening to incoming network connections.
Definition: networklistener.h:40
Pure-virtual interface class for controller. This is spammed across parties needing access to applica...
Definition: mcontroller.h:39
M of the MVC pattern. Handles permanent storage.
Definition: model.h:47
Interface for receiving network traffic.
Definition: connection.h:57
void incomingConnection(int aSocketDescriptor)
Model * iModel
Definition: networklistener.h:107
bool iCanAccept
Definition: networklistener.h:115
bool startListen(bool aIpv6)
Class that represents a network connection.
Definition: connection.h:41
NetworkListener(MController *aController, Model *aModel)
void figureOutLocalAddresses()
virtual bool dataReceived(const QByteArray &aData, Connection &aConnection)