ArnLib
4.0.x
Active Registry Network
|
An automatic client discover connector. More...
#include <ArnDiscoverConnect.hpp>
Public Slots | |
void | setService (const QString &service) |
Set the service name for the connection. More... | |
Signals | |
void | clientReadyToConnect (ArnClient *arnClient, const QString &id) |
Signal for external client connection. More... | |
Public Member Functions | |
ArnDiscoverConnector (ArnClient &client, const QString &id) | |
~ArnDiscoverConnector () | |
void | clearDirectHosts () |
Clear the direct host connection list. More... | |
void | addToDirectHosts (const QString &arnHost, quint16 port=0) |
Add an Arn Server to the direct host connection list. More... | |
void | setResolver (ArnDiscoverResolver *resolver) |
Set the ArnDiscoverResolver to be used. More... | |
void | start () |
Start connector. More... | |
QString | id () const |
Return the identifier for this connector. More... | |
QString | service () const |
Returns the service name for this connection. More... | |
int | directHostPrio () const |
Return the priority for direct hosts More... | |
void | setDirectHostPrio (int directHostPrio) |
Set the priority for direct hosts More... | |
int | discoverHostPrio () const |
Return the priority for discovered hosts More... | |
void | setDiscoverHostPrio (int discoverHostPrio) |
Set the priority for discovered hosts More... | |
int | resolveRefreshTimeout () const |
Return the resolv refresh period. More... | |
void | setResolveRefreshTimeout (int resolveRefreshTimeout) |
Set the resolv refresh period. More... | |
bool | externalClientConnect () const |
Return the external client connect mode. More... | |
void | setExternalClientConnect (bool externalClientConnect) |
Set the external client connect mode. More... | |
An automatic client discover connector.
This connector class manages client connections. Both as a list of possible direct host addresses and using a service name for reolving into a discover host. The two methods can coexist and as standard the discover host has lowest priority number, i.e. tried first.
An id is assigned to every connector. The id should be chosen to describe the client target or its purpose. It's not a host address or necessarily a specific host, as there can be many possible addresses assigned to the ArnDiscoverConnector.
The id will appear as an Arn folder, e.g. when id is "WeatherData-XYZ" the connector folder path will be "Sys/Discover/Connect/WeatherData-XYZ/".
Example usage
Definition at line 75 of file ArnDiscoverConnect.hpp.
ArnDiscoverConnector::ArnDiscoverConnector | ( | ArnClient & | client, |
const QString & | id | ||
) |
Definition at line 70 of file ArnDiscoverConnect.cpp.
ArnDiscoverConnector::~ArnDiscoverConnector | ( | ) |
Definition at line 93 of file ArnDiscoverConnect.cpp.
void ArnDiscoverConnector::addToDirectHosts | ( | const QString & | arnHost, |
quint16 | port = 0 |
||
) |
Add an Arn Server to the direct host connection list.
[in] | arnHost | is host name or ip address, e.g. "192.168.1.1". |
[in] | port | is the host port, 0 gives Arn::defaultTcpPort. |
Definition at line 107 of file ArnDiscoverConnect.cpp.
void ArnDiscoverConnector::clearDirectHosts | ( | ) |
Clear the direct host connection list.
Typically used to start making a new connection list.
Definition at line 99 of file ArnDiscoverConnect.cpp.
|
signal |
Signal for external client connection.
When activated external client connection by the method setExternalClientConnect(), this signal will be emitted when the client has been prepared to connect.
It's the responsibility of the receiver to do the actual client connect by ArnClient::connectToArnList().
[in] | arnClient | being ready for connection |
[in] | id | is the identifier used in ArnDiscoverRemote::newConnector(), e.g "WeatherData-XYZ" |
int ArnDiscoverConnector::directHostPrio | ( | ) | const |
Return the priority for direct hosts
Definition at line 177 of file ArnDiscoverConnect.cpp.
int ArnDiscoverConnector::discoverHostPrio | ( | ) | const |
Return the priority for discovered hosts
Definition at line 161 of file ArnDiscoverConnect.cpp.
bool ArnDiscoverConnector::externalClientConnect | ( | ) | const |
Return the external client connect mode.
Definition at line 193 of file ArnDiscoverConnect.cpp.
QString ArnDiscoverConnector::id | ( | ) | const |
Return the identifier for this connector.
Definition at line 137 of file ArnDiscoverConnect.cpp.
int ArnDiscoverConnector::resolveRefreshTimeout | ( | ) | const |
Return the resolv refresh period.
Definition at line 145 of file ArnDiscoverConnect.cpp.
QString ArnDiscoverConnector::service | ( | ) | const |
Returns the service name for this connection.
Definition at line 209 of file ArnDiscoverConnect.cpp.
void ArnDiscoverConnector::setDirectHostPrio | ( | int | directHostPrio | ) |
Set the priority for direct hosts
This priority controls order between direct hosts and discover host. Low priority number give earlier try for its hosts.
[in] | directHostPrio | is the priority. |
Definition at line 185 of file ArnDiscoverConnect.cpp.
void ArnDiscoverConnector::setDiscoverHostPrio | ( | int | discoverHostPrio | ) |
Set the priority for discovered hosts
This priority controls order between direct hosts and discover host. Low priority number give earlier try for its hosts.
[in] | discoverHostPrio | is the priority. |
Definition at line 169 of file ArnDiscoverConnect.cpp.
void ArnDiscoverConnector::setExternalClientConnect | ( | bool | externalClientConnect | ) |
Set the external client connect mode.
This mode is used when there is a need to do special processing when connecting a client. Then QObject::connect() should be used for the signal clientReadyToConnect() and a receiver doing the special processing.
It's the responsibility of the receiver to do the actual client connect by ArnClient::connectToArnList().
[in] | externalClientConnect | true to activate. |
Definition at line 201 of file ArnDiscoverConnect.cpp.
void ArnDiscoverConnector::setResolver | ( | ArnDiscoverResolver * | resolver | ) |
Set the ArnDiscoverResolver to be used.
The resolver handles resolving a known service name into a host name.
Ownership is taken of this resolver. Any previos set resolver will be deleted.
[in] | resolver | is the used ArnDiscoverResolver. Use 0 (null) to set none. |
Definition at line 115 of file ArnDiscoverConnect.cpp.
void ArnDiscoverConnector::setResolveRefreshTimeout | ( | int | resolveRefreshTimeout | ) |
Set the resolv refresh period.
The refresh period is used when there is a failure to connect to a discover host.
The rationale is that the current resolv might be outdated as there is an error when connecting to the resolved host. A refreshed resolv will be done at an intervall of resolveRefreshTimeout until connection to resolved host is successful.
[in] | resolveRefreshTimeout | is the period in seconds. |
Definition at line 153 of file ArnDiscoverConnect.cpp.
|
slot |
Set the service name for the connection.
This is only functional if using ArnDiscoverResolver, see setResolver().
Will update connection service name if the resolver has been setup, otherwise the service name is only stored for future use.
For remote control the service name is also available as an Arn Data Object at local path: connector folder path + "Service/value", e.g. "Sys/Discover/Connect/WeatherData-XYZ/Service/value".
[in] | service | is the requested connection service name e.g. "My House Registry" |
Definition at line 217 of file ArnDiscoverConnect.cpp.
void ArnDiscoverConnector::start | ( | ) |
Start connector.
Definition at line 228 of file ArnDiscoverConnect.cpp.