Click or drag to resize

DiscoveryHandlerLinkOsOnly Class

Class definition for a callback to be invoked for Link-OS™ printer discovery events.
Inheritance Hierarchy
SystemObject
  Zebra.Sdk.Printer.DiscoveryDiscoveryHandlerLinkOsOnly

Namespace: Zebra.Sdk.Printer.Discovery
Assembly: SdkApi.Core (in SdkApi.Core.dll) Version: 3.0.3271
Syntax
public class DiscoveryHandlerLinkOsOnly : DiscoveryHandler

The DiscoveryHandlerLinkOsOnly type exposes the following members.

Constructors
 NameDescription
Public methodDiscoveryHandlerLinkOsOnly Creates a DiscoveryHandler which will only report back Link-OS™ printers.
Top
Methods
 NameDescription
Public methodDiscoveryError 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.
Public methodDiscoveryFinished This method is invoked when discovery is finished.
Public methodEquals
(Inherited from Object)
Public methodFoundPrinter This method is invoked when a Link-OS™ printer has been discovered. This method will be invoked for each printer that is found.
Public methodGetHashCode
(Inherited from Object)
Public methodGetType
(Inherited from Object)
Public methodToString
(Inherited from Object)
Top
Example
C#
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;
        }
    }
}
See Also