Classified ads
Signals | Public Member Functions | Protected Member Functions | Private Slots | Private Member Functions | 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 ()
 

Protected Member Functions

void incomingConnection (int aSocketDescriptor)
 

Private Slots

void broadCastReceived ()
 
void threadIsDeleted ()
 

Private Member Functions

void figureOutLocalAddresses ()
 

Private Attributes

MControlleriController
 
ModeliModel
 
ProtocolMessageParseriParser
 
QUdpSocket iBroadCastListener
 
bool iCanAccept
 

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
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 ( )
private
void NetworkListener::incomingConnection ( int  aSocketDescriptor)
protected
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

MController* NetworkListener::iController
private
Model* NetworkListener::iModel
private
ProtocolMessageParser* NetworkListener::iParser
private

This animal here knows all incoming bytearrays


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