ArnLib
4.0.x
Active Registry Network
|
Registering a ZeroConfig service. More...
#include <ArnZeroConf.hpp>
Signals | |
void | registered (const QString &serviceName) |
Indicate successfull registration of service. More... | |
void | registrationError (int code) |
Indicate unsuccessfull registration of service. More... | |
Public Member Functions | |
ArnZeroConfRegister (QObject *parent=arnNullptr) | |
Standard constructor of an ArnZeroConfRegister object. More... | |
ArnZeroConfRegister (const QString &serviceName, QObject *parent=arnNullptr) | |
Constructor of an ArnZeroConfRegister object. More... | |
ArnZeroConfRegister (const QString &serviceName, const QString &serviceType, quint16 port, QObject *parent=arnNullptr) | |
Constructor of an ArnZeroConfRegister object. More... | |
virtual | ~ArnZeroConfRegister () |
Destructor of an ArnZeroConfRegister object. More... | |
QStringList | subTypes () const |
Returns the list of current subtypes. More... | |
void | setSubTypes (const QStringList &subtypes) |
Sets the list of current subtypes. More... | |
void | addSubType (const QString &subtype) |
Add a subtype to the list of current subtypes. More... | |
quint16 | port () const |
Returns the port number for connecting to the service. More... | |
void | setPort (quint16 port) |
Sets the port number for connecting to the service. More... | |
QString | serviceName () const |
Returns the service name for this Zero Config. More... | |
QString | currentServiceName () const |
Returns the current service name for this Zero Config. More... | |
void | setServiceName (const QString &name) |
Set the service name for this Zero Config. More... | |
QString | host () const |
Returns the host name for this Zero Config. More... | |
void | setHost (const QString &host) |
Set the host name for this Zero Config. More... | |
bool | getTxtRecordMap (Arn::XStringMap &xsm) |
Load a XStringMap with parameters from the Txt Record. More... | |
void | setTxtRecordMap (const Arn::XStringMap &xsm) |
Save a XStringMap with parameters to the Txt Record. More... | |
QByteArray | txtRecord () const |
Return the Txt Record for this Zero Config. More... | |
void | setTxtRecord (const QByteArray &txt) |
Set the Txt Record for this Zero Config. More... | |
void | registerService (bool noAutoRename=false) |
Register the service. More... | |
void | releaseService () |
Release the service. More... | |
![]() | |
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 |
Registering a ZeroConfig service.
This class handles registration of a ZeroConfig service. The service name can be any string, giving a clear human readable naming of the service. If the given service name is already in use, it will have a number added to make it unique. A given TXT record can be registered together with the service.
Example usage
Definition at line 366 of file ArnZeroConf.hpp.
ArnZeroConfRegister::ArnZeroConfRegister | ( | QObject * | parent = arnNullptr | ) |
Standard constructor of an ArnZeroConfRegister object.
The service name can be automatically generated based on the system's hostname.
[in] | parent |
Definition at line 375 of file ArnZeroConf.cpp.
ArnZeroConfRegister::ArnZeroConfRegister | ( | const QString & | serviceName, |
QObject * | parent = arnNullptr |
||
) |
Constructor of an ArnZeroConfRegister object.
All needed parameters for an "arn" service type, using standard arn-port at this computer.
[in] | serviceName | the human readable naming of the service, e.g. "My fantastic service". |
[in] | parent |
Definition at line 382 of file ArnZeroConf.cpp.
ArnZeroConfRegister::ArnZeroConfRegister | ( | const QString & | serviceName, |
const QString & | serviceType, | ||
quint16 | port, | ||
QObject * | parent = arnNullptr |
||
) |
Constructor of an ArnZeroConfRegister object.
All needed parameters for a service at this computer.
The service type can be a name or the standard format used by the Zeroconf specification, e.g. "_arn._tcp".
[in] | serviceName | the human readable naming of the service, e.g. "My fantastic service". |
[in] | serviceType | the service type, e.g. "arn" or "_arn._tcp". |
[in] | port | the service port num |
[in] | parent |
Definition at line 391 of file ArnZeroConf.cpp.
|
virtual |
Destructor of an ArnZeroConfRegister object.
If the service is registered, it will be unregistered.
Definition at line 403 of file ArnZeroConf.cpp.
|
inline |
Add a subtype to the list of current subtypes.
[in] | subtype | the subtype to add, e.g. "myGroup1" |
Definition at line 427 of file ArnZeroConf.hpp.
QString ArnZeroConfRegister::currentServiceName | ( | ) | const |
Returns the current service name for this Zero Config.
At first, the requested service name is returned. Later the service name is internally updated with real name when registered() signal is emitted.
Definition at line 414 of file ArnZeroConf.cpp.
|
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".
[out] | xsm | is the loaded XStringMap if successfull, otherwise undefined. |
true | if successfull. |
Definition at line 509 of file ArnZeroConf.hpp.
|
inline |
Returns the host name for this Zero Config.
Usually hostname is empty, automatically using the computers name, but it can also be like "myserver".
Definition at line 487 of file ArnZeroConf.hpp.
|
inline |
Returns the port number for connecting to the service.
the | port number |
Definition at line 434 of file ArnZeroConf.hpp.
|
signal |
Indicate successfull registration of service.
The service name will also be internally updated, it can be accesed via currentServiceName().
[in] | serviceName | is the realy registered name e.g. "My House Registry (2)" |
void ArnZeroConfRegister::registerService | ( | bool | noAutoRename = false | ) |
Register the service.
Tries to register the service on the local network.
Result is indicated by registered() and registrationError() signals.
[in] | noAutoRename | when true, registration will fail if another service with the same service type already is registered with the same service name. |
Definition at line 427 of file ArnZeroConf.cpp.
|
signal |
Indicate unsuccessfull registration of service.
[in] | code | error code. |
void ArnZeroConfRegister::releaseService | ( | ) |
Release the service.
If the service is registered, it will be unregistered. Any registration attempts in progress will be aborted.
Definition at line 472 of file ArnZeroConf.cpp.
|
inline |
Returns the service name for this Zero Config.
The returned service name is always the requested name. For real name use currentServiceName().
Definition at line 454 of file ArnZeroConf.hpp.
|
inline |
Set the host name for this Zero Config.
Usually hostname is empty, automatically using the computers name, but it can also be like "myserver".
[in] | host | is the current host name (se above) |
Definition at line 496 of file ArnZeroConf.hpp.
|
inline |
Sets the port number for connecting to the service.
When registering a service with a port number of 0, the service will not be found when browsing, but the service name will be marked as reserved.
[in] | port | the port number |
Definition at line 443 of file ArnZeroConf.hpp.
void ArnZeroConfRegister::setServiceName | ( | const QString & | name | ) |
Set the service name for this Zero Config.
Service names can be any human readable id. It should be easy to understand, without any cryptic coding, and can usually be modified by the end user.
The requested service name is not guaranted to be registered, as it has to be unique within the local network. The realy used name comes with the registered() signal and can be accessed via currentServiceName().
[in] | name | is service name, e.g. "My House Registry" |
Definition at line 420 of file ArnZeroConf.cpp.
|
inline |
Sets the list of current subtypes.
[in] | subtypes | The new list of subtypes, e.g. ("myGroup1", "myGroup2") |
Definition at line 419 of file ArnZeroConf.hpp.
|
inline |
Set the Txt Record for this Zero Config.
The binary format should be the standardized from the Zeroconfig specification. This Txt Record will typically be used later for publishing in zero config.
[in] | txt | is The Txt Record (in binary format) |
Definition at line 540 of file ArnZeroConf.hpp.
|
inline |
Save a XStringMap with parameters to the Txt Record.
The XStringMap contains the parameters to be saved into the Txt Record. This Txt Record will typically be used later for publishing in zero config.
[in] | xsm | is the XStringMap to be saved into the Txt Record. |
Definition at line 519 of file ArnZeroConf.hpp.
|
inline |
Returns the list of current subtypes.
the | subtype list, e.g. ("myGroup1", "myGroup2") |
Definition at line 410 of file ArnZeroConf.hpp.
|
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.
Definition at line 530 of file ArnZeroConf.hpp.
|
friend |
Definition at line 368 of file ArnZeroConf.hpp.