# class PublicService

###

Module | dnssd
Namespace | DNSSD
Class | PublicService
Inherits | QObject,DNSSD::ServiceBase

\class PublicService publicservice.h DNSSD/PublicService

This class is most important for application that wants to announce its service on network. Suppose that you want to make your web server public - this is simplest way:

    DNSSD.PublicService *service = new DNSSD.PublicService("My files","_http._tcp",80);
    bool isOK = service->publish();

In this example publish() is synchronous - it will not return until publishing is complete. This is usually not too long but it can freeze application's GUI for a moment. Asynchronous publishing is better for responsiveness. Example:

    DNSSD.PublicService *service = new DNSSD.PublicService("My files","_http._tcp",80);
    connect(service,SIGNAL(published(bool)),this,SLOT(wasPublished(bool)));
    service->publishAsync();

This class represents local service being published Author Jakub Stachowski

### methods

- PublicService (name, type, port, domain, subtypes)

  returns ctor

  Argument | Type | Default
  --- | --- | ---
  name | QString | QString()
  type | QString | QString()
  port | unsigned int | 0
  domain | QString | QString()
  subtypes | QStringList | QStringList()

  name - Service name. If set to QString(), computer name will be used and will be available via serviceName() after successful registration

  type - Service type. Has to be in form _sometype._udp or _sometype._tcp

  port - Port number. Set to 0 to "reserve" service name.

  domain - Domain name. If left as QString:null, user configuration will be used. "local." means local LAN

  subtypes - Optional list of subtypes. Each subtype name must have leading underscore. Example: service of type _ftp._tcp may have subtype _anon meaning that it is anonymous FTP server.

- isPublished ( )

  returns bool

  Returns true is currently published

- publish ( )

  returns bool

  Synchrounous publish. Application will be freezed until publishing is complete. Returns true if successful.

- publishAsync ( )

  returns Nothing

  Asynchronous version of publish(). It return immediately and emits signal published(bool) when completed. Note that in case of early detected error (like bad service type) signal may be emitted before return of this function.

- published (a0)

  returns Nothing
  SIGNAL ("published (bool)")

  Argument | Type | Default
  --- | --- | ---
  a0 | bool |

  Emitted when publishing is complete - parameter is set to true if it was successful. It will also emitted when name, port or type of already published service is changed.

- setDomain (domain)

  returns Nothing

  Argument | Type | Default
  --- | --- | ---
  domain | QString |

  Sets domain where service is published. "local." means local LAN. If service is currently published, it will be re-announced with new data.

- setPort (port)

  returns Nothing

  Argument | Type | Default
  --- | --- | ---
  port | unsigned short |

  Sets port. If service is currently published, it will be re-announced with new data.

- setServiceName (serviceName)

  returns Nothing

  Argument | Type | Default
  --- | --- | ---
  serviceName | QString |

  Sets name of the service. If service is currently published, it will be re-announced with new data.

- setSubTypes (subtypes)

  returns Nothing

  Argument | Type | Default
  --- | --- | ---
  subtypes | QStringList |

  Sets subtypetypes of service. Pass empty list to remove subtype. If service is currently published, it will be re-announced with new data.

- setTextData (textData)

  returns Nothing

  Argument | Type | Default
  --- | --- | ---
  textData | QMap<QString,QByteArray> |

  Sets new text properties. If services is already published, it will be re-announced with new data.

- setType (type)

  returns Nothing

  Argument | Type | Default
  --- | --- | ---
  type | QString |

  Sets type of service. It has to in form of _type._udp or _type._tcp. If service is currently published, it will be re-announced with new data.

- stop ( )

  returns Nothing

  Stops publishing or abort incomplete publish request. Useful when you want to disable service for some time.

- subtypes ( )

  returns QStringList

  Returns otpional subtype of service. It is always empty for domains and in most cases empty for normal services.

- virtual_hook (a0, a1)

  returns Nothing

  Argument | Type | Default
  --- | --- | ---
  a0 | int |
  a1 | void |