ArnLib  4.0.x
Active Registry Network
ArnDiscoverResolver Class Reference

Resolv an Arn service. More...

#include <ArnDiscover.hpp>

Inheritance diagram for ArnDiscoverResolver:
Collaboration diagram for ArnDiscoverResolver:

Public Slots

int resolve (const QString &serviceName, bool forceUpdate=true)
 Resolve a specific service name. More...
 

Public Member Functions

 ArnDiscoverResolver (QObject *parent=arnNullptr)
 
QString defaultService () const
 Return the default service name. More...
 
void setDefaultService (const QString &defaultService)
 Set the default service name. More...
 
- Public Member Functions inherited from ArnDiscoverBrowserB
 ArnDiscoverBrowserB (QObject *parent=arnNullptr)
 
 ~ArnDiscoverBrowserB ()
 
int serviceCount () const
 Return the number of active discover services. More...
 
const ArnDiscoverInfoinfoByIndex (int index)
 Return the discover service info by its index. More...
 
const ArnDiscoverInfoinfoById (int id)
 Return the discover service info by its id. More...
 
const ArnDiscoverInfoinfoByName (const QString &serviceName)
 Return the discover service info by its name. More...
 
int indexToId (int index)
 Return the discover service id by its index. More...
 
int IdToIndex (int id)
 Return the discover service index by its id. More...
 
int serviceNameToId (const QString &name)
 Return the discover service id by its name. More...
 
ArnDiscoverInfo::State defaultStopState () const
 Return the default stop state for this service discover browser. More...
 
void setDefaultStopState (ArnDiscoverInfo::State defaultStopState)
 Set the default stop state for this service discover browser. More...
 
bool goTowardState (int index, ArnDiscoverInfo::State state)
 Command a service to go towards a stop state. More...
 

Additional Inherited Members

- Signals inherited from ArnDiscoverBrowserB
void serviceAdded (int index, const QString &name)
 Indicate service has been added (discovered) More...
 
void serviceRemoved (int index)
 Indicate service has been removed. More...
 
void infoUpdated (int index, ArnDiscoverInfo::State state)
 Indicate service has been updated. More...
 

Detailed Description

Resolv an Arn service.

About Arn Discover

Example usage

// In class declare
ArnDiscoverResolver* _resolver;
// In class code
_resolver = new ArnDiscoverResolver( this);
connect( _resolver, SIGNAL(infoUpdated(int,ArnDiscoverInfo::State)),
this, SLOT(doClientResolvChanged(int,ArnDiscoverInfo::State)));
_resolver->resolve("My service");
void XXX::doClientResolvChanged( int index, ArnDiscoverInfo::State state)
{
const ArnDiscoverInfo& info = _resolver->infoByIndex( index);
if (state == state.HostIp) {
qDebug() << "Resolved service:" << info.serviceName()
<< " into host:" << info.hostWithInfo();
}
else if (info.isError()) {
qDebug() << "Error resolving service:" << info.serviceName()
<< " code:" << info.resolvCode();
}
}
Examples:
ArnDemoChat/MainWindow.cpp.

Definition at line 556 of file ArnDiscover.hpp.

Constructor & Destructor Documentation

◆ ArnDiscoverResolver()

ArnDiscoverResolver::ArnDiscoverResolver ( QObject *  parent = arnNullptr)
explicit

Definition at line 256 of file ArnDiscover.cpp.

Member Function Documentation

◆ defaultService()

QString ArnDiscoverResolver::defaultService ( ) const

Return the default service name.

This default service name will be used when resolve() is called with empty service name.

Returns
default service name, e.g. "Arn Default Service"
See also
setDefaultService()
resolve()

Definition at line 276 of file ArnDiscover.cpp.

◆ resolve

int ArnDiscoverResolver::resolve ( const QString &  serviceName,
bool  forceUpdate = true 
)
slot

Resolve a specific service name.

Only the specified service will be resolved, but there can be many ongoing resolves by calling this method multiple times with different service names. The infoUpdated() signal will always be emitted when calling this method. The signal can also be emitted multiple times later regarding the same service.

Parameters
[in]serviceNameis the service to be resolved
[in]forceUpdatewhen true, a new resolve is always done, otherwise a service name that already is resolved will not be resolved again.
Returns
index to service info
See also
indexToId()
infoUpdated()

Definition at line 268 of file ArnDiscover.cpp.

◆ setDefaultService()

void ArnDiscoverResolver::setDefaultService ( const QString &  defaultService)

Set the default service name.

This default service name will be used when resolve() is called with empty service name. If calling with defaultService empty, it is ignored.

Parameters
[in]defaultServicee.g. "My Default Service"
See also
defaultService()
resolve()

Definition at line 284 of file ArnDiscover.cpp.


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