ArnLib
4.0.x
Active Registry Network
|
Discover with remote setting. More...
#include <ArnDiscoverRemote.hpp>
Public Slots | |
virtual void | setService (const QString &service) |
Set the service name. More... | |
![]() | |
virtual void | setService (const QString &service) |
Set the service name. More... | |
Signals | |
void | clientReadyToConnect (ArnClient *arnClient, const QString &id) |
Central signal for external client connection. More... | |
![]() | |
void | serviceChanged (const QString &serviceName) |
Indicate successfull advertise of service. More... | |
void | serviceChangeError (int code) |
Indicate unsuccessfull advertise of service. More... | |
Public Member Functions | |
ArnDiscoverRemote (QObject *parent=arnNullptr) | |
~ArnDiscoverRemote () | |
QString | defaultService () const |
Return the default service name. More... | |
void | setDefaultService (const QString &defaultService) |
Set the default service name. More... | |
int | initialServiceTimeout () const |
Return the time for initial timeout processing. More... | |
void | setInitialServiceTimeout (int initialServiceTimeout) |
Set the time for initial timeout processing. More... | |
void | startUseServer (ArnServer *arnServer, ArnDiscover::Type discoverType=ArnDiscover::Type::Server) |
Start advertising the ArnServer as a service. More... | |
void | startUseNewServer (ArnDiscover::Type discoverType, int port=-1) |
Start a new ArnServer and advertise as a service. More... | |
ArnDiscoverConnector * | newConnector (ArnClient &client, const QString &id) |
Create and return an ArnDiscoverConnector for handling remote client. More... | |
![]() | |
ArnDiscoverAdvertise (QObject *parent=arnNullptr) | |
~ArnDiscoverAdvertise () | |
QStringList | groups () const |
Return service discover groups used for filter browsing. More... | |
void | setGroups (const QStringList &groups) |
Set service discover groups used for filter browsing. More... | |
void | addGroup (const QString &group) |
Add a service discover group. More... | |
QString | service () const |
Returns the requested service name for this Advertise. More... | |
QString | currentService () const |
Returns the current service name for this Advertise. More... | |
State | state () const |
Returns the state for this Advertise. More... | |
void | advertiseService (ArnDiscover::Type discoverType, const QString &serviceName, int port=-1, const QString &hostName=QString()) |
Start advertising the service. More... | |
Arn::XStringMap | customProperties () const |
Return service custom properties. More... | |
void | setCustomProperties (const Arn::XStringMap &customProperties) |
Set service custom properties. More... | |
void | addCustomProperty (const QString &key, const QString &val) |
Add service custom property. More... | |
Discover with remote setting.
This class is the main class for handling discover with remote setting.
Following rules apply:
For a complete example of advertisng a server, see the project ArnServer in ServerMain.hpp and ServerMain.cpp files.
Example usage
Definition at line 94 of file ArnDiscoverRemote.hpp.
|
explicit |
Definition at line 63 of file ArnDiscoverRemote.cpp.
ArnDiscoverRemote::~ArnDiscoverRemote | ( | ) |
Definition at line 75 of file ArnDiscoverRemote.cpp.
|
signal |
Central signal for external client connection.
When activated external client connection by the connector method ArnDiscoverConnector::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 newConnector(), e.g "WeatherData-XYZ" |
QString ArnDiscoverRemote::defaultService | ( | ) | const |
Return the default service name.
Definition at line 238 of file ArnDiscoverRemote.cpp.
int ArnDiscoverRemote::initialServiceTimeout | ( | ) | const |
Return the time for initial timeout processing.
Definition at line 255 of file ArnDiscoverRemote.cpp.
ArnDiscoverConnector * ArnDiscoverRemote::newConnector | ( | ArnClient & | client, |
const QString & | id | ||
) |
Create and return an ArnDiscoverConnector for handling remote client.
The ArnDiscoverConnector is internally connected to this ArnDiscoverRemote.
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 folder path will be "Sys/Discover/Connect/WeatherData-XYZ/".
[in] | client | |
[in] | id | identifies the target of the client connection, e.g "WeatherData-XYZ" |
Definition at line 141 of file ArnDiscoverRemote.cpp.
void ArnDiscoverRemote::setDefaultService | ( | const QString & | defaultService | ) |
Set the default service name.
This default service name will be used when no service has been set before timeout. If calling with defaultService empty, it's ignored.
[in] | defaultService | e.g. "My Default Service" |
Definition at line 246 of file ArnDiscoverRemote.cpp.
void ArnDiscoverRemote::setInitialServiceTimeout | ( | int | initialServiceTimeout | ) |
Set the time for initial timeout processing.
Initial timeout-processing can wait upto this time, after that defaultService() will be used as service.
[in] | initialServiceTimeout | in seconds |
Definition at line 263 of file ArnDiscoverRemote.cpp.
|
virtualslot |
Set the service name.
Will update current advertised service name if this advertiser has been setup, otherwise the service name is stored for future use.
For remote control the service name is also available as an Arn Data Object at local path "Sys/Discover/This/Service/value".
All the functionaly from ArnDiscoverAdvertise::setService() apply.
[in] | service | is the requested service name e.g. "My House Registry" |
Definition at line 221 of file ArnDiscoverRemote.cpp.
void ArnDiscoverRemote::startUseNewServer | ( | ArnDiscover::Type | discoverType, |
int | port = -1 |
||
) |
Start a new ArnServer and advertise as a service.
Handle advertising an internally created ArnServer as a service on the local network.
This method is typically used when there is no need to access the ArnServer class, which usually is the case in an client application. The ArnServer is then merely used to make the discover functionality remote controlled.
All the functionaly from startUseServer() do apply.
[in] | discoverType | is used for discover filtering |
[in] | port | is the port of the service, -1 gives Arn::defaultTcpPort, 0 gives dynamic port |
Definition at line 128 of file ArnDiscoverRemote.cpp.
void ArnDiscoverRemote::startUseServer | ( | ArnServer * | arnServer, |
ArnDiscover::Type | discoverType = ArnDiscover::Type::Server |
||
) |
Start advertising the ArnServer as a service.
Handle advertising of an existing ArnServer as a service on the local network. Everything is fully automatic, including remote setting service name and support for persistent storage of the name. Status can be accessed via Arn Data Objects.
[in] | arnServer | is the ArnServer to be advertised |
[in] | discoverType | is used for discover filtering |
Definition at line 80 of file ArnDiscoverRemote.cpp.