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: 2.15.2634
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
Determines whether the specified object is equal to the current object.
(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
Serves as the default hash function.
(Inherited from Object.)
Public methodGetType
Gets the Type of the current instance.
(Inherited from Object.)
Public methodToString
Returns a string that represents the current object.
(Inherited from Object.)
Top
Examples
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