Classified ads
Signals | Public Member Functions | Protected Member Functions | Private Slots | Private Attributes | List of all members
NetworkListener Class Reference

class for listening to incoming network connections. More...

#include <networklistener.h>

Inheritance diagram for NetworkListener:
Inheritance graph
[legend]
Collaboration diagram for NetworkListener:
Collaboration graph
[legend]

Signals

void error (QTcpSocket::SocketError socketError)
 
void nodeConnectionAttemptStatus (Connection::ConnectionState aStatus, const Hash aHashOfAttemptedNode)
 

Public Member Functions

 NetworkListener (MController *aController, Model *aModel)
 
 ~NetworkListener ()
 
bool startListen (bool aIpv6)
 
virtual bool dataReceived (const QByteArray &aData, Connection &aConnection)
 
virtual void connectionClosed (Connection *aDeletee)
 
virtual void connectionReady (Connection *aBusinessEntity)
 
void stopAccepting ()
 
void figureOutLocalAddresses ()
 

Protected Member Functions

void incomingConnection (int aSocketDescriptor)
 

Private Slots

void broadCastReceived ()
 
void threadIsDeleted ()
 
void networkStateChanged (QNetworkSession::State aState)
 
void connectionAttemptFailed (const Hash &aNodeHash)
 

Private Attributes

MControlleriController
 
ModeliModel
 
ProtocolMessageParseriParser
 
QUdpSocket iBroadCastListener
 
bool iCanAccept
 
QNetworkConfiguration iConnectionConfig
 
QNetworkSession * iNetworkSession
 

Detailed Description

class for listening to incoming network connections.

This class will spawn a Connection for each received network connection.

Constructor & Destructor Documentation

NetworkListener::NetworkListener ( MController aController,
Model aModel 
)

Constructor

Parameters
aControllerapplication controller for app state frobnication
aModeldata model reference for data storage
aIpv6if set to true, this class will listen in Ipv6 instead of v4 and will not enumerate local network interfaces.
NetworkListener::~NetworkListener ( )

Destructor

Member Function Documentation

void NetworkListener::broadCastReceived ( )
privateslot
void NetworkListener::connectionAttemptFailed ( const Hash aNodeHash)
privateslot

This slot is used to communicate situation where connection-attempt to node fails

Parameters
aNodeHashfingerprint of failed node
virtual void NetworkListener::connectionClosed ( Connection aDeletee)
virtual

From ConnectionObserver this is called by peer connection at close

Implements Connection::ConnectionObserver.

virtual void NetworkListener::connectionReady ( Connection aBusinessEntity)
virtual

From ConnectionObserver this is called by peer connection at successful open

Implements Connection::ConnectionObserver.

virtual bool NetworkListener::dataReceived ( const QByteArray &  aData,
Connection aConnection 
)
virtual

from ConnectionObserver

Implements Connection::ConnectionObserver.

void NetworkListener::error ( QTcpSocket::SocketError  socketError)
signal
void NetworkListener::figureOutLocalAddresses ( )

Method that loops network interfaces and tries to find a valid local address to advertise

void NetworkListener::incomingConnection ( int  aSocketDescriptor)
protected
void NetworkListener::networkStateChanged ( QNetworkSession::State  aState)
privateslot
void NetworkListener::nodeConnectionAttemptStatus ( Connection::ConnectionState  aStatus,
const Hash  aHashOfAttemptedNode 
)
signal

this signal is used to communicate (at least to publishing engine) status of connection attempt to particular node. network connection engine will spawn connections to more-or-less random nodes but publishing logic may ask for connections to specific nodes. this signal will communicate outcome of such requests

bool NetworkListener::startListen ( bool  aIpv6)

separate method for starting the listen. this now works with qt4.8 but it seems like semantics of listen may change in qt5, where listening in QHostAddress::Any automatically means both v4 and v6.

Parameters
aIpv6if true, tries to listen on both IPv6 and ipv4.
Returns
true if listening started.
void NetworkListener::stopAccepting ( )

used in closing of app: stops accepting connections

void NetworkListener::threadIsDeleted ( )
privateslot

Member Data Documentation

QUdpSocket NetworkListener::iBroadCastListener
private
bool NetworkListener::iCanAccept
private

used in closing of application: flag for not accepting connections any more

QNetworkConfiguration NetworkListener::iConnectionConfig
private
MController* NetworkListener::iController
private
Model* NetworkListener::iModel
private
QNetworkSession* NetworkListener::iNetworkSession
private
ProtocolMessageParser* NetworkListener::iParser
private

This animal here knows all incoming bytearrays


The documentation for this class was generated from the following file: