ArnLib  4.0.x
Active Registry Network
ArnZeroConfResolve Class Reference

Resolv a ZeroConfig service. More...

#include <ArnZeroConf.hpp>

Inheritance diagram for ArnZeroConfResolve:
Collaboration diagram for ArnZeroConfResolve:

Signals

void resolved (int id, const QByteArray &escFullDomain)
 Indicate successfull resolve of service. More...
 
void resolveError (int id, int code)
 Indicate unsuccessfull resolve of service. More...
 

Public Member Functions

 ArnZeroConfResolve (QObject *parent=arnNullptr)
 Standard constructor of an ArnZeroConfResolv object. More...
 
 ArnZeroConfResolve (const QString &serviceName, QObject *parent=arnNullptr)
 Constructor of an ArnZeroConfResolv object. More...
 
 ArnZeroConfResolve (const QString &serviceName, const QString &serviceType, QObject *parent=arnNullptr)
 Constructor of an ArnZeroConfResolv object. More...
 
virtual ~ArnZeroConfResolve ()
 Destructor of an ArnZeroConfResolv object. More...
 
int id () const
 Returns the id number for this resolv. More...
 
void setId (int id)
 Sets the id number for this this resolv. More...
 
QString host () const
 Returns the host name for this resolv. More...
 
quint16 port () const
 Returns the port number for connecting to the service. More...
 
QString serviceName () const
 Returns the service name used for this resolv. More...
 
void setServiceName (const QString &name)
 Set the service name used for this resolv. More...
 
bool getTxtRecordMap (Arn::XStringMap &xsm)
 Load a XStringMap with parameters from the Txt Record. More...
 
QByteArray txtRecord () const
 Return the Txt Record for this Zero Config. More...
 
void resolve (bool forceMulticast=false)
 Resolve the service. More...
 
void releaseResolve ()
 Release the resolving. More...
 
- Public Member Functions inherited from ArnZeroConfB
 ArnZeroConfB (QObject *parent=arnNullptr)
 
virtual ~ArnZeroConfB ()
 
QAbstractSocket::SocketType socketType () const
 Returns the socket type for this Zero Config. More...
 
void setSocketType (QAbstractSocket::SocketType type)
 Sets the socket type for this Zero Config. More...
 
QString serviceType () const
 Returns the service type for this Zero Config. More...
 
void setServiceType (const QString &type)
 Returns the service type for this Zero Config. More...
 
QString domain () const
 Returns the domain for this Zero Config. More...
 
void setDomain (const QString &domain)
 Sets the domain for this Zero Config. More...
 
ArnZeroConf::State state () const
 Returns the current state of the service. More...
 
QString fullServiceType () const
 Returns the full service type for this Zero Config. More...
 

Friends

class ArnZeroConfIntern
 

Detailed Description

Resolv a ZeroConfig service.

About Zero Config

This class handles resolving of a ZeroConfig service. The service name can be given directly if known, but typically it comes from ArnZeroConfBrowser.

Example usage

// In class code
ArnZeroConfResolve* ds = new ArnZeroConfResolve("My TestService. In the attic", this);
ds->setId( myId); // Optional id, later used in the signals
connect( ds, SIGNAL(resolveError(int,int)), this, SLOT(onResolveError(int,int)));
connect( ds, SIGNAL(resolved(int,QByteArray)), this, SLOT(onResolved(int,QByteArray)));
ds->resolve();
void XXX::onResolved( int id, QByteArray escFullDomain)
{
ArnZeroConfResolve* ds = qobject_cast<ArnZeroConfResolve*>( sender());
ds->getTxtRecordMap( xsmPar);
QString info = QString()
+ " Domain=" + ds->domain()
+ " Host=" + ds->host()
+ " Port=" + QString::number( ds->port())
+ " Txt: " + QString::fromUtf8( xsmPar.toXString().constData());
QString ver = xsmPar.valueString("MyVers");
ds->releaseService();
ds->deleteLater();
}

Definition at line 616 of file ArnZeroConf.hpp.

Constructor & Destructor Documentation

◆ ArnZeroConfResolve() [1/3]

ArnZeroConfResolve::ArnZeroConfResolve ( QObject *  parent = arnNullptr)

Standard constructor of an ArnZeroConfResolv object.

Parameters
[in]parent

Definition at line 528 of file ArnZeroConf.cpp.

◆ ArnZeroConfResolve() [2/3]

ArnZeroConfResolve::ArnZeroConfResolve ( const QString &  serviceName,
QObject *  parent = arnNullptr 
)

Constructor of an ArnZeroConfResolv object.

All needed parameters for an "arn" service type.

Parameters
[in]serviceNamethe human readable naming of the service, e.g. "My fantastic service".
[in]parent

Definition at line 535 of file ArnZeroConf.cpp.

◆ ArnZeroConfResolve() [3/3]

ArnZeroConfResolve::ArnZeroConfResolve ( const QString &  serviceName,
const QString &  serviceType,
QObject *  parent = arnNullptr 
)

Constructor of an ArnZeroConfResolv object.

All needed parameters for a service.

The service type can be a name or the standard format used by the Zeroconf specification, e.g. "_arn._tcp".

Parameters
[in]serviceNamethe human readable naming of the service, e.g. "My fantastic service".
[in]serviceTypethe service type, e.g. "arn" or "_arn._tcp".
[in]parent

Definition at line 544 of file ArnZeroConf.cpp.

◆ ~ArnZeroConfResolve()

ArnZeroConfResolve::~ArnZeroConfResolve ( )
virtual

Destructor of an ArnZeroConfResolv object.

If the service is registered, it will be unregistered.

Definition at line 555 of file ArnZeroConf.cpp.

Member Function Documentation

◆ getTxtRecordMap()

bool ArnZeroConfResolve::getTxtRecordMap ( Arn::XStringMap xsm)
inline

Load a XStringMap with parameters from the Txt Record.

It is assumed that the Txt Record has already been received.

After loading XStringMap is successfull it contains the parameters from the Txt Record, e.g. Arn::XStringMap::toXString() can return "protovers=1.0 MyParam=xyz".

Parameters
[out]xsmis the loaded XStringMap if successfull, otherwise undefined.
Return values
trueif successfull.
See also
Arn::XStringMap

Definition at line 703 of file ArnZeroConf.hpp.

◆ host()

QString ArnZeroConfResolve::host ( ) const
inline

Returns the host name for this resolv.

Hostname contain domain, e.g. "myserver.local".

Returns
current host name (se above)

Definition at line 670 of file ArnZeroConf.hpp.

◆ id()

int ArnZeroConfResolve::id ( ) const

Returns the id number for this resolv.

Returns
the id number
See also
setId()

Definition at line 565 of file ArnZeroConf.cpp.

◆ port()

quint16 ArnZeroConfResolve::port ( ) const
inline

Returns the port number for connecting to the service.

Return values
theport number

Definition at line 676 of file ArnZeroConf.hpp.

◆ releaseResolve()

void ArnZeroConfResolve::releaseResolve ( )

Release the resolving.

Any resolve attempts in progress will be aborted.

Definition at line 615 of file ArnZeroConf.cpp.

◆ resolve()

void ArnZeroConfResolve::resolve ( bool  forceMulticast = false)

Resolve the service.

Tries to resolve the service to determine the host and port necessary to establish a connection.

Result is indicated by resolved() and resolveError() signals.

Parameters
[in]forceMulticastwhen true, ArnZeroConfResolv will use a multicast request to resolve the service, even if the host name is a unicast address, i.e. outside the local network.
See also
resolved()
resolveError()

Definition at line 577 of file ArnZeroConf.cpp.

◆ resolved

void ArnZeroConfResolve::resolved ( int  id,
const QByteArray &  escFullDomain 
)
signal

Indicate successfull resolve of service.

Parameters
[in]idis the id number for this resolve
[in]escFullDomainis the raw full domain with esc sequences
See also
resolve()

◆ resolveError

void ArnZeroConfResolve::resolveError ( int  id,
int  code 
)
signal

Indicate unsuccessfull resolve of service.

Parameters
[in]idis the id number for this resolve
[in]codeis the error code.
See also
resolve()

◆ serviceName()

QString ArnZeroConfResolve::serviceName ( ) const
inline

Returns the service name used for this resolv.

Returns
current service name, e.g. "My House Registry"

Definition at line 682 of file ArnZeroConf.hpp.

◆ setId()

void ArnZeroConfResolve::setId ( int  id)

Sets the id number for this this resolv.

This id can be used to identify different resolves when using a common handler.

When not set, it will be automatically assigned during resolve().

Parameters
[in]idthe id number
See also
id()

Definition at line 571 of file ArnZeroConf.cpp.

◆ setServiceName()

void ArnZeroConfResolve::setServiceName ( const QString &  name)
inline

Set the service name used for this resolv.

Service names can be any human readable id. It will be used when reolving the service.

Parameters
[in]nameis service name, e.g. "My House Registry"
See also
serviceName()

Definition at line 691 of file ArnZeroConf.hpp.

◆ txtRecord()

QByteArray ArnZeroConfResolve::txtRecord ( ) const
inline

Return the Txt Record for this Zero Config.

It is assumed that the Txt Record has already been received.

The binary format should be the standardized from the Zeroconfig specification.

Returns
The Txt Record (in binary format)
See also
getTxtRecordMap()

Definition at line 713 of file ArnZeroConf.hpp.

Friends And Related Function Documentation

◆ ArnZeroConfIntern

friend class ArnZeroConfIntern
friend

Definition at line 618 of file ArnZeroConf.hpp.


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