ZeroConfBrowser
Overview
The ZeroConfBrowser class provides methods for receiving information about the ZeroConf environment and services registered in it.
Use Case
This class can be used in a client application to discover services registered within ZeroConf service provider. To start using this class perform the following steps:
- Create an instance of the ZeroConfBrowser class and set its Type property to the full name of the service to browse for (i.e. '_bonjourdiscoverableservice_rosdk._tcp' ).
- Add event handlers for the ServiceAdded and ServiceRemoved events to handle appearing/disappearing services, respectively. For example:
private void ZeroConfBrowser_ServiceAdded(object sender, ZeroConfBrowseResultArgs args)
{
ZeroConfService service = args.Record;
if (service.TryResolve())
//Some actions here to handle information about newly appeared service
LogMessage(String.Format("Added service: {0} at port {1}", args.Record.Name, args.Record.Port));
}
private void ZeroConfBrowser_ServiceRemoved(object sender, ZeroConfBrowseResultArgs args)
{
ZeroConfService service = args.Record;
//Some actions here to handle information about disappeared service
LogMessage(String.Format("Service has gone down: {0} (at host {1}:{2})", service.HostTarget, service.HostTarget, service.Port));
}
- To start receiving information about registered / unregistered services set the Active property to true.
Note: Take a look at the Bonjour Discovery Sample (.NET) shipped with the Remoting SDK to see service discovery in action.
Location
- Reference: RemObjects.SDK.ZeroConf.dll
- Namespace: RemObjects.SDK.ZeroConf
- Ancestry: Component | ZeroConfBrowser
constructor
Creates a new instance of the ZeroConfBrowser class.
constructor
ZeroConfBrowser()
Sub New()
Active
Determines if the service browser is currently active. Setting this property to true initiates a service search.
property Active: Boolean read write;
Boolean Active { get; set; }
Property Active() As Boolean
AllLocalServices
String constant that specifies the special service type name used for discovering all local services.
const AllLocalServices: String = "_services._dns-sd._udp.";
const String AllLocalServices = "_services._dns-sd._udp."
Dim AllLocalServices As String = "_services._dns-sd._udp."
Dispose protected
Releases all resources used by the current class instance.
method Dispose(disposing: Boolean)
void Dispose(Boolean disposing)
Sub Dispose(disposing As Boolean)
Parameters:
- disposing: true to release both managed and unmanaged resources; false to release only unmanaged resources.
Domain
Gets or sets the domain name where the ZeroConfBrowser will search for services.
Currently only the '.local' domain is supported.
property Domain: String read write;
String Domain { get; set; }
Property Domain() As String
Error
This event is raised when an error occurs during service browsing.
event Error: EventHandler<ZeroConfBrowseErrorEventArgs>;
delegate EventHandler<ZeroConfBrowseErrorEventArgs> Error()
Event Error As EventHandler<ZeroConfBrowseErrorEventArgs>
OnError protected
Raises the Error event.
method OnError(error: Exception)
void OnError(Exception error)
Sub OnError(error As Exception)
Parameters:
- error: Exception occurred
Results
Gets a list of the ZeroConfService instances that represent the services already discovered by the ZeroConf browser.
property Results: IList<ZeroConfService> read;
IList<ZeroConfService> Results { get; }
ReadOnly Property Results() As IList<ZeroConfService>
ServiceAdded
This event is raised when a new service is discovered. The ZeroConfBrowseResult property will hold a reference to the ZeroConfService instance that can be used to additional receive information about the discovered service.
event ServiceAdded: EventHandler<ZeroConfBrowseResultEventArgs>;
delegate EventHandler<ZeroConfBrowseResultEventArgs> ServiceAdded()
Event ServiceAdded As EventHandler<ZeroConfBrowseResultEventArgs>
ServiceRemoved
This event is raised when a service is no longer available. The ZeroConfBrowseResult property will hold a reference to the ZeroConfService instance that can be used to additional receive information about the service.
event ServiceRemoved: EventHandler<ZeroConfBrowseResultEventArgs>;
delegate EventHandler<ZeroConfBrowseResultEventArgs> ServiceRemoved()
Event ServiceRemoved As EventHandler<ZeroConfBrowseResultEventArgs>
Stop
Cancels the service search.
method Stop
void Stop()
Sub Stop()
SynchronizeObject
Gets or sets a ISynchronizeInvoke instance that will be used to raise events in a synchronousl way.
property SynchronizeObject: ISynchronizeInvoke read write;
ISynchronizeInvoke SynchronizeObject { get; set; }
Property SynchronizeObject() As ISynchronizeInvoke
SyncRoot
Gets an object that can be used to synchronize assess to the Results collection.
property SyncRoot: Object read;
Object SyncRoot { get; }
ReadOnly Property SyncRoot() As Object
Type
Gets or sets the full name of the service to browse for.
property Type: String read write;
String Type { get; set; }
Property Type() As String
AllLocalServices
String constant that specifies the special service type name used for discovering all local services.
const AllLocalServices: String = "_services._dns-sd._udp.";
const String AllLocalServices = "_services._dns-sd._udp."
Dim AllLocalServices As String = "_services._dns-sd._udp."
Active
Determines if the service browser is currently active. Setting this property to true initiates a service search.
property Active: Boolean read write;
Boolean Active { get; set; }
Property Active() As Boolean
Domain
Gets or sets the domain name where the ZeroConfBrowser will search for services.
Currently only the '.local' domain is supported.
property Domain: String read write;
String Domain { get; set; }
Property Domain() As String
Results
Gets a list of the ZeroConfService instances that represent the services already discovered by the ZeroConf browser.
property Results: IList<ZeroConfService> read;
IList<ZeroConfService> Results { get; }
ReadOnly Property Results() As IList<ZeroConfService>
SynchronizeObject
Gets or sets a ISynchronizeInvoke instance that will be used to raise events in a synchronousl way.
property SynchronizeObject: ISynchronizeInvoke read write;
ISynchronizeInvoke SynchronizeObject { get; set; }
Property SynchronizeObject() As ISynchronizeInvoke
SyncRoot
Gets an object that can be used to synchronize assess to the Results collection.
property SyncRoot: Object read;
Object SyncRoot { get; }
ReadOnly Property SyncRoot() As Object
Type
Gets or sets the full name of the service to browse for.
property Type: String read write;
String Type { get; set; }
Property Type() As String
constructor
Creates a new instance of the ZeroConfBrowser class.
constructor
ZeroConfBrowser()
Sub New()
Dispose protected
Releases all resources used by the current class instance.
method Dispose(disposing: Boolean)
void Dispose(Boolean disposing)
Sub Dispose(disposing As Boolean)
Parameters:
- disposing: true to release both managed and unmanaged resources; false to release only unmanaged resources.
OnError protected
Raises the Error event.
method OnError(error: Exception)
void OnError(Exception error)
Sub OnError(error As Exception)
Parameters:
- error: Exception occurred
Stop
Cancels the service search.
method Stop
void Stop()
Sub Stop()
Error
This event is raised when an error occurs during service browsing.
event Error: EventHandler<ZeroConfBrowseErrorEventArgs>;
delegate EventHandler<ZeroConfBrowseErrorEventArgs> Error()
Event Error As EventHandler<ZeroConfBrowseErrorEventArgs>
ServiceAdded
This event is raised when a new service is discovered. The ZeroConfBrowseResult property will hold a reference to the ZeroConfService instance that can be used to additional receive information about the discovered service.
event ServiceAdded: EventHandler<ZeroConfBrowseResultEventArgs>;
delegate EventHandler<ZeroConfBrowseResultEventArgs> ServiceAdded()
Event ServiceAdded As EventHandler<ZeroConfBrowseResultEventArgs>
ServiceRemoved
This event is raised when a service is no longer available. The ZeroConfBrowseResult property will hold a reference to the ZeroConfService instance that can be used to additional receive information about the service.
event ServiceRemoved: EventHandler<ZeroConfBrowseResultEventArgs>;
delegate EventHandler<ZeroConfBrowseResultEventArgs> ServiceRemoved()
Event ServiceRemoved As EventHandler<ZeroConfBrowseResultEventArgs>
- [Bonjour Discovery Sample (.NET)BonjourDiscovery
- ZeroConf