Heart 1.3.842.34c2ab5
Heart is base back end library for your c++ Qt projects.
QH::AbstractNode Class Referenceabstract

The AbstractNode class - Abstract implementation of node. this implementation have a methods for send and receive data messages, and work with crypto method for create a security connections betwin nodes. AbstractNode - is thread save class. More...

#include <abstractnode.h>

Inheritance diagram for QH::AbstractNode:
Inheritance graph
Collaboration diagram for QH::AbstractNode:
Collaboration graph

Public Types

enum  NodeType : int { Client = 0 , Node = 1 , Server = 2 }
 The NodeType enum contains types of the node. By default node contains only 3 types. More...
 

Signals

void requestError (unsigned char code, QString msg)
 requestError This signal emited when client or node received from remoute server or node the BadRequest package.
 
void sigNoLongerSupport (const QString &ApiKey, unsigned short version)
 sigNoLongerSupport is some as a APIVersionParser::sigNoLongerSupport. This signal just retronslate this signal as direct connection.
 

Public Member Functions

 AbstractNode (QObject *ptr=nullptr)
 AbstractNode - Base constructor of node.
 
 ~AbstractNode () override
 
virtual NodeType nodeType () const =0
 nodeType This method should be return type of the serve.
 
virtual bool run (const QString &addres, unsigned short port)
 run This method implement deployment a network node (server) on selected address.
 
QSharedPointer< QH::iParserselectParser (unsigned short cmd, AbstractNodeInfo *sender) const
 selectParser This method select parser by command and sender.
 
QSharedPointer< QH::iParserselectParser (const QString &type, int version) const
 selectParser This method select parser by command and sender.
 
QSharedPointer< QH::iParserselectParser (const QString &type, AbstractNodeInfo *sender) const
 selectParser This method select parser by command and sender.
 
virtual void stop ()
 stop - Stopped this node and close all network connections.
 
virtual AbstractNodeInfogetInfoPtr (const HostAddress &id)
 getInfoPtr - This method return information class pointer about netwok connection. If Connection with id not found then return nullptr.
 
virtual const AbstractNodeInfogetInfoPtr (const HostAddress &id) const
 getInfoPtr - This is some that getInfoPtr(const HostAddress &id) bod it is constant implementation.
 
virtual void ban (const HostAddress &target)
 ban - This method set for target connection a trust property to 0 and target connection will been aborted.
 
virtual void unBan (const HostAddress &target)
 unBan - This method set for target connection a trust property to 100.
 
virtual unsigned int sendData (const PKG::AbstractData *resp, const HostAddress &address, const Header *req=nullptr)
 sendData This method send data object another to node
 
virtual unsigned int sendData (const PKG::AbstractData *resp, const AbstractNodeInfo *node, const Header *req=nullptr)
 sendData This method send data object another to node
 
bool addNode (const HostAddress &address)
 addNode - Connect to node (server) with address.
 
bool addNode (const HostAddress &address, const std::function< void(QH::AbstractNodeInfo *)> &action, NodeCoonectionStatus status=NodeCoonectionStatus::Connected)
 addNode This method add new peer connection to this node and execute the action when node status will be changed to the status.
 
bool addNode (const QString &domain, unsigned short port, const std::function< void(QH::AbstractNodeInfo *)> &action=nullptr, NodeCoonectionStatus status=NodeCoonectionStatus::Connected)
 addNode This method add new peer connection to this node and execute the action when node status will be changed to the status.
 
bool removeNode (const HostAddress &nodeAdderess)
 removeNode - Remove node and disconnected forom node (server).
 
bool removeNode (AbstractNodeInfo *node)
 removeNode - Remove node and disconnected forom node (server).
 
HostAddress address () const
 address - Thim method return own network address of current node (server).
 
SslMode getMode () const
 getMode - This method return SSL mode of corrent node (server).
 
virtual WorkState getWorkState () const
 getWorkState - This method collect general information about this server. For more information about returned data see getWorkState
 
int connectionsCount () const
 connectionsCount - Return count fo connections (connections with status connected)
 
int confirmendCount () const
 connectionsCount - Return count of nodes with status confirmend.
 
bool ping (const HostAddress &address)
 ping This method send ping package to address for testing connection.
 
bool sheduleTask (const QSharedPointer< AbstractTask > &task)
 sheduleTask This method shedule execute task on this node.
 
void removeTask (int taskId)
 removeTask This method remove task from sheduler.
 
int sheduledTaskCount () const
 sheduledTaskCount This method return count of sheduled tasks.
 
virtual void badRequest (const HostAddress &address, const Header &req, const PKG::ErrorData &err, qint8 diff=REQUEST_ERROR)
 badRequest This method is send data about error of request.
 
bool addApiParser (const QSharedPointer< iParser > &parser)
 addApiParser This method add new Api parser for this node.
 
bool fSendBadRequestErrors () const
 fSendBadRequestErrors This property enable or disable sending feedback to connected node when them sent wrong packages.
 
void setSendBadRequestErrors (bool value)
 setSendBadRequestErrors This method enable or disable the fSendBadRequestErrors property.
 
bool fCloseConnectionAfterBadRequest () const
 fCloseConnectionAfterBadRequest This propery enable or disable droping connection after badRequests. By default it is true.
 
void setCloseConnectionAfterBadRequest (bool value)
 setSendBadRequestErrors This method enable or disable the fcloseConnectionAfterBadRequest property.
 
- Public Member Functions inherited from QH::SoftDelete
 SoftDelete ()
 
virtual ~SoftDelete ()
 ~SoftDelete This destructor has bin crashed if the softDelete method not will be invoked before delete this object. IF you try delete this object on release distribution then you get error message only without invoked std::abort method.
 
void softDelete ()
 softDelete This method remove this object and save all changes into database.
 

Static Public Member Functions

static QThread * mainThreadID ()
 mainThreadID This method return the pointer to main thread
 

Protected Slots

virtual void receivePing (const QSharedPointer< QH::PKG::Ping > &ping)
 receivePing This method invoked when node receive new ping object.
 

Protected Member Functions

virtual AbstractNodeInfocreateNodeInfo (QAbstractSocket *socket, const HostAddress *clientAddress=nullptr) const
 createNodeInfo This method create a nodeInfo object. override this method for create your own nodeInfo objects. for more in
 
virtual bool registerSocket (QAbstractSocket *socket, const HostAddress *address=nullptr)
 registerSocket This method registration new socket object.
 
virtual bool sendPackage (const Package &pkg, QAbstractSocket *target) const
 sendPackage This method prepare and send to target address a package.
 
virtual QString getWorkStateString () const
 getWorkStateString This method generate string about work state of server.
 
virtual QString connectionState () const
 connectionState This method return string value about the cocction state.
 
QList< HostAddressbanedList () const
 banedList This method retrun list of banned clients of nodes.
 
virtual bool isBanned (const AbstractNodeInfo *socket) const
 isBanned This method checks if the node is banned.
 
void incomingConnection (qintptr handle) override final
 incomingConnection This is ovverided method of QTCPServer.
 
virtual bool changeTrust (const HostAddress &id, int diff)
 changeTrust This method change trust of connected node.
 
QHash< HostAddress, AbstractNodeInfo * > connections () const
 connections - Return hash map of all connections of this node.
 
virtual void nodeConfirmend (AbstractNodeInfo *node)
 nodeConfirmend This method invocked when the node status changed to "confirmend" default implementatio do nothing.
 
virtual void nodeConnected (AbstractNodeInfo *node)
 nodeConnected This method invocked when the node status changed to "connected" default implementatio do nothing.
 
virtual void nodeDisconnected (AbstractNodeInfo *node)
 nodeConnected This method invocked when the node status changed to "disconnected" default implementatio do nothing.
 
void prepareForDelete () override
 prepareForDelete This method must be prepare object for delete. Override this for working main functions of this class. For more information see the SoftDelete class and SoftDelete::~SoftDelete distructor.
 
QSharedPointer< PKG::AbstractDataprepareData (const Package &pkg, AbstractNodeInfo *sender) const
 prepareData This is private method for preparing package from the byteArray.
 
QList< HostAddressconnectionsList () const
 connectionsList This method return list of all node connections
 
QList< HostAddressactiveConnectionsList () const
 activeConnectionsList This method return list of actived nodes connections
 
virtual void addNodeFailed (AddNodeError error)
 addNodeFailed This method will be invoked when trying to add new node are failed. So override this method for handle this event.
 
virtual void nodeAddedSucessful (AbstractNodeInfo *node)
 nodeAddedSucessful This method will be invoked when new node added successful.
 
template<class ApiType , class ... Args>
QSharedPointer< ApiType > addApiParserNative (Args &&... arg)
 addApiParserNative This is template metod that add sipport of new apiparser ApiType
 
template<class ApiType , class ... Args>
const QSharedPointer< iParser > & addApiParser (Args &&... arg)
 addApiParser This is template metod that add sipport of new apiparser ApiType
 
virtual void nodeErrorOccured (QH::AbstractNodeInfo *nodeInfo, QAbstractSocket::SocketError errorCode, QString errorString)
 nodeErrorOccured This slot invoked when error ocured in the nodeInfo.
 

Friends

class WebSocketController
 
class SocketFactory
 
class BigDataParser
 
class BigDataParserOld
 
class AbstractNodeParser
 
class AbstractNodeParserOld
 

Detailed Description

The AbstractNode class - Abstract implementation of node. this implementation have a methods for send and receive data messages, and work with crypto method for create a security connections betwin nodes. AbstractNode - is thread save class.

Note
For correctly working this class you should be register all you dataParser types using the AbstractNode::addApiParser method.
See also
AbstractData
iParser
AbstractNode::addApiParser

Definition at line 100 of file abstractnode.h.

Member Enumeration Documentation

◆ NodeType

The NodeType enum contains types of the node. By default node contains only 3 types.

Enumerator
Client 

Node with this type is general clints nodes.

Node 

Node with this ytpe is midle nodes that can works as a client and as servers.

Server 

This is node can works only as a public server.

Definition at line 109 of file abstractnode.h.

Constructor & Destructor Documentation

◆ AbstractNode()

QH::AbstractNode::AbstractNode ( QObject *  ptr = nullptr)

AbstractNode - Base constructor of node.

Parameters
ptr- Pointrt to parent Qt object, the AbstractNode class is Q_OBJECT.
Note
For correctly working this class you should be register all you data types using the AbstractNode::registerPackageType method.

Definition at line 52 of file abstractnode.cpp.

Here is the call graph for this function:

◆ ~AbstractNode()

QH::AbstractNode::~AbstractNode ( )
override

Definition at line 90 of file abstractnode.cpp.

Member Function Documentation

◆ activeConnectionsList()

QList< HostAddress > QH::AbstractNode::activeConnectionsList ( ) const
protected

activeConnectionsList This method return list of actived nodes connections

Returns
list of actived nodes connections.
Warning
do not use this method for validation is connected.

Definition at line 988 of file abstractnode.cpp.

Here is the caller graph for this function:

◆ addApiParser() [1/2]

template<class ApiType , class ... Args>
const QSharedPointer< iParser > & QH::AbstractNode::addApiParser ( Args &&...  arg)
inlineprotected

addApiParser This is template metod that add sipport of new apiparser ApiType

Template Parameters
ApiTypeThis is type of new apiParser that will be added to the main parser.
ArgsThis is argumets that will forward to the Parser constructor.
Returns
shared pointer to the iParser

Definition at line 644 of file abstractnode.h.

◆ addApiParser() [2/2]

bool QH::AbstractNode::addApiParser ( const QSharedPointer< iParser > &  parser)

addApiParser This method add new Api parser for this node.

Parameters
parserObjectThis is bew api parser.
Returns
added parser.

Definition at line 1030 of file abstractnode.cpp.

◆ addApiParserNative()

template<class ApiType , class ... Args>
QSharedPointer< ApiType > QH::AbstractNode::addApiParserNative ( Args &&...  arg)
inlineprotected

addApiParserNative This is template metod that add sipport of new apiparser ApiType

Template Parameters
ApiTypeThis is type of new apiParser that will be added to the main parser.
ArgsThis is argumets that will forward to the Parser constructor.
Returns
shared pointer to the ApiType

Definition at line 633 of file abstractnode.h.

◆ addNode() [1/3]

bool QH::AbstractNode::addNode ( const HostAddress address)

addNode - Connect to node (server) with address.

Parameters
address- This is Network address of node (server).
Returns
true if the node aaded successful
See also
AbstractNode::nodeAddedSucessful
AbstractNode::addNodeFailed

Definition at line 206 of file abstractnode.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ addNode() [2/3]

bool QH::AbstractNode::addNode ( const HostAddress address,
const std::function< void(QH::AbstractNodeInfo *)> &  action,
NodeCoonectionStatus  status = NodeCoonectionStatus::Connected 
)

addNode This method add new peer connection to this node and execute the action when node status will be changed to the status.

Parameters
addressThis is address of peer node.
actionThis is action that will be executed when status will changed to required status.
statusThis is required status.
Returns
true if node added successful.
Note
The Action do not executed when node alredy connected.
If you override the nodeConfirmend or the nodeConnected method then you must be invoke parent implementation else action do not executed.
See also
AbstractNode::nodeAddedSucessful
AbstractNode::addNodeFailed

Definition at line 235 of file abstractnode.cpp.

Here is the call graph for this function:

◆ addNode() [3/3]

bool QH::AbstractNode::addNode ( const QString &  domain,
unsigned short  port,
const std::function< void(QH::AbstractNodeInfo *)> &  action = nullptr,
NodeCoonectionStatus  status = NodeCoonectionStatus::Connected 
)

addNode This method add new peer connection to this node and execute the action when node status will be changed to the status.

Parameters
domain- This is domain address of node (server).
port- This is target port of node (server).
actionThis is action that will be executed when status will changed to required status. You can ignore this argument for disable actions after connect.
statusThis is required status. You can ignore this argument. By default it is Connected state
Returns
true if node added successful.

Example of use:

Note
The Action do not executed when node alredy connected.
If you override the nodeConfirmend or the nodeConnected method then you must be invoke parent implementation else action do not executed.
See also
AbstractNode::nodeAddedSucessful
AbstractNode::addNodeFailed

Definition at line 249 of file abstractnode.cpp.

Here is the call graph for this function:

◆ addNodeFailed()

void QH::AbstractNode::addNodeFailed ( AddNodeError  error)
protectedvirtual

addNodeFailed This method will be invoked when trying to add new node are failed. So override this method for handle this event.

Parameters
errorThis is error code that occured after invoke of the AbstractNode::addNode method
See also
AbstractNode::addNode
AbstractNode::nodeAddedSucessful

Definition at line 1002 of file abstractnode.cpp.

Here is the caller graph for this function:

◆ address()

HostAddress QH::AbstractNode::address ( ) const

address - Thim method return own network address of current node (server).

Returns
The current network adderss.

Definition at line 320 of file abstractnode.cpp.

Here is the caller graph for this function:

◆ badRequest()

void QH::AbstractNode::badRequest ( const HostAddress address,
const Header req,
const PKG::ErrorData err,
qint8  diff = REQUEST_ERROR 
)
virtual

badRequest This method is send data about error of request.

Parameters
addressThis is addrees of receiver.
reqThis is header of incomming request.
errThis is message and code of error. For more information see the ErrorData struct.
diffThis is difference of current trust (currenTrus += diff). By default diff equals REQUEST_ERROR

Definition at line 643 of file abstractnode.cpp.

Here is the call graph for this function:

◆ ban()

void QH::AbstractNode::ban ( const HostAddress target)
virtual

ban - This method set for target connection a trust property to 0 and target connection will been aborted.

Parameters
target- It is network address of target connection.

Definition at line 189 of file abstractnode.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ banedList()

QList< HostAddress > QH::AbstractNode::banedList ( ) const
protected

banedList This method retrun list of banned clients of nodes.

Returns
list of baned nodes.

Definition at line 707 of file abstractnode.cpp.

Here is the caller graph for this function:

◆ changeTrust()

bool QH::AbstractNode::changeTrust ( const HostAddress id,
int  diff 
)
protectedvirtual

changeTrust This method change trust of connected node.

Parameters
idThis is id of select node.
diffThis is difference of current trust (currenTrus += diff).
Returns
true if node trust is changed successful.

Definition at line 802 of file abstractnode.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ confirmendCount()

int QH::AbstractNode::confirmendCount ( ) const

connectionsCount - Return count of nodes with status confirmend.

Returns
return confirmend connections of this node (server).

Definition at line 734 of file abstractnode.cpp.

◆ connections()

QHash< HostAddress, AbstractNodeInfo * > QH::AbstractNode::connections ( ) const
protected

connections - Return hash map of all connections of this node.

Returns
return map of connections.

Definition at line 1130 of file abstractnode.cpp.

◆ connectionsCount()

int QH::AbstractNode::connectionsCount ( ) const

connectionsCount - Return count fo connections (connections with status connected)

Returns
Count valid connections.

Definition at line 721 of file abstractnode.cpp.

Here is the caller graph for this function:

◆ connectionsList()

QList< HostAddress > QH::AbstractNode::connectionsList ( ) const
protected

connectionsList This method return list of all node connections

Returns
list of node connections.
Warning
do not use this method for validation is connected.

Definition at line 982 of file abstractnode.cpp.

Here is the caller graph for this function:

◆ connectionState()

QString QH::AbstractNode::connectionState ( ) const
protectedvirtual

connectionState This method return string value about the cocction state.

Returns
string with count users state.

Definition at line 703 of file abstractnode.cpp.

Here is the call graph for this function:

◆ createNodeInfo()

AbstractNodeInfo * QH::AbstractNode::createNodeInfo ( QAbstractSocket *  socket,
const HostAddress clientAddress = nullptr 
) const
protectedvirtual

createNodeInfo This method create a nodeInfo object. override this method for create your own nodeInfo objects. for more in

Parameters
socketThis is socket of network address.
clientAddressThis parameter need to set when the socket du not contains a address or invalid.
Returns
return pointer to info object.

Definition at line 484 of file abstractnode.cpp.

Here is the caller graph for this function:

◆ fCloseConnectionAfterBadRequest()

bool QH::AbstractNode::fCloseConnectionAfterBadRequest ( ) const

fCloseConnectionAfterBadRequest This propery enable or disable droping connection after badRequests. By default it is true.

Returns
true if the clossing connection is enabled and false if disabled.

Definition at line 463 of file abstractnode.cpp.

Here is the caller graph for this function:

◆ fSendBadRequestErrors()

bool QH::AbstractNode::fSendBadRequestErrors ( ) const

fSendBadRequestErrors This property enable or disable sending feedback to connected node when them sent wrong packages.

Returns
true if the sending feedbacks is enabled and false if disabled.

Definition at line 471 of file abstractnode.cpp.

◆ getInfoPtr() [1/2]

AbstractNodeInfo * QH::AbstractNode::getInfoPtr ( const HostAddress id)
virtual

getInfoPtr - This method return information class pointer about netwok connection. If Connection with id not found then return nullptr.

Parameters
id- It is network address of requested node.
Returns
The pointer of information about node. if address not found return nullptr.

Definition at line 167 of file abstractnode.cpp.

Here is the caller graph for this function:

◆ getInfoPtr() [2/2]

const AbstractNodeInfo * QH::AbstractNode::getInfoPtr ( const HostAddress id) const
virtual

getInfoPtr - This is some that getInfoPtr(const HostAddress &id) bod it is constant implementation.

Parameters
id- It is network address of requested node.
Returns
The pointer of information about node. if address not found return nullptr.

Definition at line 179 of file abstractnode.cpp.

◆ getMode()

SslMode QH::AbstractNode::getMode ( ) const

getMode - This method return SSL mode of corrent node (server).

Returns
current mode for more information see SslMode.

Definition at line 1126 of file abstractnode.cpp.

◆ getWorkState()

WorkState QH::AbstractNode::getWorkState ( ) const
virtual

getWorkState - This method collect general information about this server. For more information about returned data see getWorkState

Returns
state value for more information see WorkState class.

Definition at line 678 of file abstractnode.cpp.

Here is the call graph for this function:

◆ getWorkStateString()

QString QH::AbstractNode::getWorkStateString ( ) const
protectedvirtual

getWorkStateString This method generate string about work state of server.

Returns
string of work state.

Definition at line 691 of file abstractnode.cpp.

Here is the call graph for this function:

◆ incomingConnection()

void QH::AbstractNode::incomingConnection ( qintptr  handle)
finaloverrideprotected

incomingConnection This is ovverided method of QTCPServer.

Parameters
handleThis is socket handle.

Definition at line 761 of file abstractnode.cpp.

Here is the call graph for this function:

◆ isBanned()

bool QH::AbstractNode::isBanned ( const AbstractNodeInfo socket) const
protectedvirtual

isBanned This method checks if the node is banned.

Parameters
socketThis is node info object for validation.
Returns
true if node is banned.

Definition at line 753 of file abstractnode.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ mainThreadID()

QThread * QH::AbstractNode::mainThreadID ( )
static

mainThreadID This method return the pointer to main thread

Returns
pointer to main thread

Definition at line 1248 of file abstractnode.cpp.

◆ nodeAddedSucessful()

void QH::AbstractNode::nodeAddedSucessful ( AbstractNodeInfo node)
protectedvirtual

nodeAddedSucessful This method will be invoked when new node added successful.

Parameters
nodeThis is pointer to added node.
Note
do not try remove the node pointer. This pointer will be removed automaticaly.
See also
AbstractNode::addNode
AbstractNode::addNodeFailed

Definition at line 1026 of file abstractnode.cpp.

Here is the caller graph for this function:

◆ nodeConfirmend()

void QH::AbstractNode::nodeConfirmend ( AbstractNodeInfo node)
protectedvirtual

nodeConfirmend This method invocked when the node status changed to "confirmend" default implementatio do nothing.

Parameters
nodeThis is address of changed node.

Definition at line 1174 of file abstractnode.cpp.

Here is the call graph for this function:

◆ nodeConnected()

void QH::AbstractNode::nodeConnected ( AbstractNodeInfo node)
protectedvirtual

nodeConnected This method invocked when the node status changed to "connected" default implementatio do nothing.

Parameters
nodeThis is address of changed node.

Definition at line 1182 of file abstractnode.cpp.

Here is the call graph for this function:

◆ nodeDisconnected()

void QH::AbstractNode::nodeDisconnected ( AbstractNodeInfo node)
protectedvirtual

nodeConnected This method invocked when the node status changed to "disconnected" default implementatio do nothing.

Parameters
nodeThis is address of changed node.

Definition at line 1194 of file abstractnode.cpp.

◆ nodeErrorOccured()

void QH::AbstractNode::nodeErrorOccured ( QH::AbstractNodeInfo nodeInfo,
QAbstractSocket::SocketError  errorCode,
QString  errorString 
)
protectedvirtual

nodeErrorOccured This slot invoked when error ocured in the nodeInfo.

Parameters
nodeInfoThis is pinter to modeInfoObject.
errorCodeThis is error code.
errorStringThis is string value of the error.
Note
default implementation do nothing. Override this method if you want to handle nodes network errors.

Definition at line 1198 of file abstractnode.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ nodeType()

virtual NodeType QH::AbstractNode::nodeType ( ) const
pure virtual

nodeType This method should be return type of the serve.

Returns
node type q qq

◆ ping()

bool QH::AbstractNode::ping ( const HostAddress address)

ping This method send ping package to address for testing connection.

Parameters
addressThis is address of target node (server).
Returns
true if ping sendet successful.

Definition at line 747 of file abstractnode.cpp.

Here is the call graph for this function:

◆ prepareData()

QSharedPointer< AbstractData > QH::AbstractNode::prepareData ( const Package pkg,
AbstractNodeInfo sender 
) const
protected

prepareData This is private method for preparing package from the byteArray.

Parameters
pkgThis is a raw package value.
senderThis is sender of the pkg.
Returns
pointer into prepared data.
Warning
The return value do not clear automatically.

Definition at line 966 of file abstractnode.cpp.

Here is the call graph for this function:

◆ prepareForDelete()

void QH::AbstractNode::prepareForDelete ( )
overrideprotectedvirtual

prepareForDelete This method must be prepare object for delete. Override this for working main functions of this class. For more information see the SoftDelete class and SoftDelete::~SoftDelete distructor.

Implements QH::SoftDelete.

Definition at line 1134 of file abstractnode.cpp.

Here is the call graph for this function:

◆ receivePing

void QH::AbstractNode::receivePing ( const QSharedPointer< QH::PKG::Ping > &  ping)
protectedvirtualslot

receivePing This method invoked when node receive new ping object.

Parameters
pingThis is ping object.

Definition at line 1038 of file abstractnode.cpp.

Here is the caller graph for this function:

◆ registerSocket()

bool QH::AbstractNode::registerSocket ( QAbstractSocket *  socket,
const HostAddress address = nullptr 
)
protectedvirtual

registerSocket This method registration new socket object.

Parameters
socketThis is incomming socket pointer.
addressThis is host address of socket. By default is nullptr. Set this value for nodes created on this host.
Returns
return true if the scoeket has been registered successful.

Definition at line 489 of file abstractnode.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ removeNode() [1/2]

bool QH::AbstractNode::removeNode ( AbstractNodeInfo node)

removeNode - Remove node and disconnected forom node (server).

Parameters
node- This is removed node (server).
Returns
true if the node removed successful. If the nde with nodeAdderess is not exits return false.

Definition at line 299 of file abstractnode.cpp.

Here is the call graph for this function:

◆ removeNode() [2/2]

bool QH::AbstractNode::removeNode ( const HostAddress nodeAdderess)

removeNode - Remove node and disconnected forom node (server).

Parameters
nodeAdderess- This is network adddress of removed node (server).
Returns
true if the node removed successful. If the nde with nodeAdderess is not exits return false.

Definition at line 290 of file abstractnode.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ removeTask()

void QH::AbstractNode::removeTask ( int  taskId)

removeTask This method remove task from sheduler.

Parameters
taskIdThis is task id that will be removed.
See also
AbstractNode::sheduleTask
AbstractNode::sheduledTaskCount

Definition at line 1044 of file abstractnode.cpp.

Here is the call graph for this function:

◆ requestError

void QH::AbstractNode::requestError ( unsigned char  code,
QString  msg 
)
signal

requestError This signal emited when client or node received from remoute server or node the BadRequest package.

Parameters
codeThis is code of error.
msg- received text of remoute node (server).

◆ run()

bool QH::AbstractNode::run ( const QString &  addres,
unsigned short  port 
)
virtual

run This method implement deployment a network node (server) on selected address.

Parameters
addresThis is network address of work node or server. If address is empty then server weel be listen all addreses of all interfaces else listen only selected address.
portThis is port of deployment node (server)
Returns
Result of deployment node (sever). (True if deploy finished successful else false).

Definition at line 108 of file abstractnode.cpp.

Here is the call graph for this function:

◆ selectParser() [1/3]

QSharedPointer< iParser > QH::AbstractNode::selectParser ( const QString &  type,
AbstractNodeInfo sender 
) const

selectParser This method select parser by command and sender.

Parameters
typethis is parser type.
senderthis is node that sent this command.
Returns
parser for the cmd command

Definition at line 137 of file abstractnode.cpp.

Here is the call graph for this function:

◆ selectParser() [2/3]

QSharedPointer< iParser > QH::AbstractNode::selectParser ( const QString &  type,
int  version 
) const

selectParser This method select parser by command and sender.

Parameters
typethis is parser type.
versionthis is node that sent this command.
Returns
parser for the cmd command

Definition at line 142 of file abstractnode.cpp.

Here is the call graph for this function:

◆ selectParser() [3/3]

QSharedPointer< iParser > QH::AbstractNode::selectParser ( unsigned short  cmd,
AbstractNodeInfo sender 
) const

selectParser This method select parser by command and sender.

Parameters
cmdthis is command that need to parse.
senderthis is node that sent this command.
Returns
parser for the cmd command

Definition at line 132 of file abstractnode.cpp.

Here is the call graph for this function:

◆ sendData() [1/2]

unsigned int QH::AbstractNode::sendData ( const PKG::AbstractData resp,
const AbstractNodeInfo node,
const Header req = nullptr 
)
virtual

sendData This method send data object another to node

Parameters
respThis is pointer to sendet object.
addressThis is target addres for sending.
reqThis is header of request.
Returns
hash of the sendet package. If function is failed then return 0.

Definition at line 594 of file abstractnode.cpp.

Here is the call graph for this function:

◆ sendData() [2/2]

unsigned int QH::AbstractNode::sendData ( const PKG::AbstractData resp,
const HostAddress address,
const Header req = nullptr 
)
virtual

sendData This method send data object another to node

Parameters
respThis is pointer to sendet object.
addressThis is target addres for sending.
reqThis is header of request.
Returns
hash of the sendet package. If function is failed then return 0.

Definition at line 588 of file abstractnode.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ sendPackage()

bool QH::AbstractNode::sendPackage ( const Package pkg,
QAbstractSocket *  target 
) const
protectedvirtual

sendPackage This method prepare and send to target address a package.

Parameters
pkgThis is sendet pakcage to target node.
targetThis is target node.
Returns
return true if The package is sendet succesfull.
Note
All packages sendets on the sender threaed. But thread of the node is wait for sends result. This is done that allthe data that is sent when node are dissconected come without fail.

Definition at line 568 of file abstractnode.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setCloseConnectionAfterBadRequest()

void QH::AbstractNode::setCloseConnectionAfterBadRequest ( bool  value)

setSendBadRequestErrors This method enable or disable the fcloseConnectionAfterBadRequest property.

Parameters
valueThis is new value of the fcloseConnectionAfterBadRequest property.

Definition at line 467 of file abstractnode.cpp.

◆ setSendBadRequestErrors()

void QH::AbstractNode::setSendBadRequestErrors ( bool  value)

setSendBadRequestErrors This method enable or disable the fSendBadRequestErrors property.

Parameters
valueThis is new value of the sendBadRequestErrors property.

Definition at line 475 of file abstractnode.cpp.

◆ sheduledTaskCount()

int QH::AbstractNode::sheduledTaskCount ( ) const

sheduledTaskCount This method return count of sheduled tasks.

Returns
count of sheduled tasks.
See also
AbstractNode::sheduleTask
AbstractNode::removeTask

Definition at line 1048 of file abstractnode.cpp.

Here is the call graph for this function:

◆ sheduleTask()

bool QH::AbstractNode::sheduleTask ( const QSharedPointer< AbstractTask > &  task)

sheduleTask This method shedule execute task on this node.

Parameters
taskThis is task that will be sheduled.
Returns
true if task added successfull else flase
See also
AbstractNode::removeTask
AbstractNode::sheduledTaskCount

Definition at line 1040 of file abstractnode.cpp.

Here is the call graph for this function:

◆ sigNoLongerSupport

void QH::AbstractNode::sigNoLongerSupport ( const QString &  ApiKey,
unsigned short  version 
)
signal

sigNoLongerSupport is some as a APIVersionParser::sigNoLongerSupport. This signal just retronslate this signal as direct connection.

Parameters
ApiKeysee the APIVersionParser::sigNoLongerSupport description
versionsee the APIVersionParser::sigNoLongerSupport description
See also
APIVersionParser::sigNoLongerSupport
Here is the caller graph for this function:

◆ stop()

void QH::AbstractNode::stop ( )
virtual

stop - Stopped this node and close all network connections.

Definition at line 146 of file abstractnode.cpp.

Here is the caller graph for this function:

◆ unBan()

void QH::AbstractNode::unBan ( const HostAddress target)
virtual

unBan - This method set for target connection a trust property to 100.

Parameters
target- It is network address of target connection.

Definition at line 196 of file abstractnode.cpp.

Friends And Related Symbol Documentation

◆ AbstractNodeParser

friend class AbstractNodeParser
friend

Definition at line 815 of file abstractnode.h.

◆ AbstractNodeParserOld

friend class AbstractNodeParserOld
friend

Definition at line 816 of file abstractnode.h.

◆ BigDataParser

friend class BigDataParser
friend

Definition at line 813 of file abstractnode.h.

◆ BigDataParserOld

friend class BigDataParserOld
friend

Definition at line 814 of file abstractnode.h.

◆ SocketFactory

friend class SocketFactory
friend

Definition at line 812 of file abstractnode.h.

◆ WebSocketController

friend class WebSocketController
friend

Definition at line 811 of file abstractnode.h.


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