DiscoveryHandlerLinkOsOnly Class |
Namespace: Zebra.Sdk.Printer.Discovery
The DiscoveryHandlerLinkOsOnly type exposes the following members.
Name | Description | |
---|---|---|
DiscoveryHandlerLinkOsOnly |
Creates a DiscoveryHandler which will only report back Link-OS™ printers.
|
Name | Description | |
---|---|---|
DiscoveryError |
This method is invoked when there is an error during discovery. The discovery will be cancelled when this method
is invoked. DiscoveryFinished will not be called if this method is invoked.
| |
DiscoveryFinished |
This method is invoked when discovery is finished.
| |
Equals | Determines whether the specified object is equal to the current object. (Inherited from Object.) | |
FoundPrinter |
This method is invoked when a Link-OS™ printer has been discovered. This method will be invoked for each printer
that is found.
| |
GetHashCode | Serves as the default hash function. (Inherited from Object.) | |
GetType | Gets the Type of the current instance. (Inherited from Object.) | |
ToString | Returns a string that represents the current object. (Inherited from Object.) |
using System; using System.Collections.Generic; using Zebra.Sdk.Printer.Discovery; public class DiscoveryHandlerLinkOsOnlyExample { public static void Main(string[] args) { try { Console.WriteLine("Starting Link-OS(TM) printer discovery."); LinkOsDiscoveryHandler discoHandler = new LinkOsDiscoveryHandler(); NetworkDiscoverer.FindPrinters(new DiscoveryHandlerLinkOsOnly(discoHandler)); while (!discoHandler.DiscoveryComplete) { System.Threading.Thread.Sleep(10); } } catch (DiscoveryException e) { Console.WriteLine(e.ToString()); } } private class LinkOsDiscoveryHandler : DiscoveryHandler { private bool discoveryComplete = false; List<DiscoveredPrinter> printers = new List<DiscoveredPrinter>(); public void DiscoveryError(string message) { Console.WriteLine($"An error occurred during discovery: {message}."); discoveryComplete = true; } public void DiscoveryFinished() { foreach (DiscoveredPrinter printer in printers) { Console.WriteLine(printer); } Console.WriteLine($"Discovered {printers.Count} Link-OS(TM) printers."); discoveryComplete = true; } public void FoundPrinter(DiscoveredPrinter printer) { printers.Add(printer); } public bool DiscoveryComplete { get => discoveryComplete; } } }