NetworkDiscoverer Class |
Namespace: Zebra.Sdk.Printer.Discovery
The NetworkDiscoverer type exposes the following members.
Name | Description | |
---|---|---|
DirectedBroadcast(DiscoveryHandler, String) |
Sends a directed broadcast discovery packet to the subnet specified by ipAddress.
| |
DirectedBroadcast(DiscoveryHandler, String, Int32) |
Sends a directed broadcast discovery packet to the subnet specified by ipAddress.
| |
Equals | Determines whether the specified object is equal to the current object. (Inherited from Object.) | |
FindPrinters(DiscoveryHandler) |
This method will search the network using a combination of discovery methods to find printers on the network.
| |
FindPrinters(DiscoveryHandler, ListString) |
Sends a discovery request to the list of printer DNS names or IPs in printersToFind.
| |
FindPrinters(DiscoveryHandler, ListString, Int32) |
Sends a discovery request to the list of printer DNS names or IPs in printersToFind.
| |
GetHashCode | Serves as the default hash function. (Inherited from Object.) | |
GetType | Gets the Type of the current instance. (Inherited from Object.) | |
LocalBroadcast(DiscoveryHandler) |
Sends a local broadcast packet.
| |
LocalBroadcast(DiscoveryHandler, Int32) |
Sends a local broadcast packet.
| |
Multicast(DiscoveryHandler, Int32) |
Sends a multicast discovery packet.
| |
Multicast(DiscoveryHandler, Int32, Int32) |
Sends a multicast discovery packet.
| |
SubnetSearch(DiscoveryHandler, String) |
Sends a discovery packet to the IPs specified in the subnetRange.
| |
SubnetSearch(DiscoveryHandler, String, Int32) |
Sends a discovery packet to the IPs specified in the subnetRange.
| |
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 NetworkDiscovererExample { public static void Main(string[] args) { try { Console.WriteLine("Starting printer discovery."); NetworkDiscoveryHandler discoveryHandler = new NetworkDiscoveryHandler(); NetworkDiscoverer.FindPrinters(discoveryHandler); while (!discoveryHandler.DiscoveryComplete) { System.Threading.Thread.Sleep(10); } } catch (DiscoveryException e) { Console.WriteLine(e.ToString()); } } private class NetworkDiscoveryHandler : 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™ printers."); discoveryComplete = true; } public void FoundPrinter(DiscoveredPrinter printer) { printers.Add(printer); } public bool DiscoveryComplete { get => discoveryComplete; } } }
using Android.App; using Android.OS; using Android.Views; using Android.Widget; using System; using System.Collections.Generic; using System.Threading; using System.Threading.Tasks; using Zebra.Sdk.Printer.Discovery; public class NetworkDiscovererExample : Activity { protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); LinearLayout layout = (LinearLayout)View.Inflate(this, Android.Resource.Layout.ActivityListItem, null); layout.Orientation = Orientation.Vertical; Button testButton = new Button(this) { Text = "Run Network Discovery Example", LayoutParameters = new ViewGroup.LayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WrapContent, ViewGroup.LayoutParams.WrapContent)) }; layout.AddView(testButton); SetContentView(layout); testButton.Click += async (sender, e) => { await Task.Run(() => { NetworkDiscoveryHandler discoveryHandler = new NetworkDiscoveryHandler(); NetworkDiscoverer.FindPrinters(discoveryHandler); while (!discoveryHandler.DiscoveryComplete) { Thread.Sleep(10); } foreach (DiscoveredPrinter printer in discoveryHandler.DiscoveredPrinters) { Console.WriteLine(printer); } Console.WriteLine($"Discovered {discoveryHandler.DiscoveredPrinters.Count} Link-OS™ printers."); }); }; } private class NetworkDiscoveryHandler : DiscoveryHandler { public void DiscoveryError(string message) { Console.WriteLine($"An error occurred during discovery: {message}."); DiscoveryComplete = true; } public void DiscoveryFinished() { DiscoveryComplete = true; } public void FoundPrinter(DiscoveredPrinter printer) { DiscoveredPrinters.Add(printer); } public bool DiscoveryComplete { get; private set; } = false; public List<DiscoveredPrinter> DiscoveredPrinters { get; } = new List<DiscoveredPrinter>(); } }
using CoreGraphics; using System; using System.Collections.Generic; using System.Threading; using System.Threading.Tasks; using UIKit; using Zebra.Sdk.Printer.Discovery; public class NetworkDiscovererExample : UIViewController { public NetworkDiscovererExample(IntPtr handle) : base(handle) { UIButton testButton = new UIButton(UIButtonType.System) { Frame = new CGRect(25, 25, 300, 150) }; testButton.SetTitle("Run Network Discovery Example", UIControlState.Normal); testButton.TouchUpInside += async (sender, e) => { await Task.Run(() => { NetworkDiscoveryHandler discoveryHandler = new NetworkDiscoveryHandler(); NetworkDiscoverer.FindPrinters(discoveryHandler); while (!discoveryHandler.DiscoveryComplete) { Thread.Sleep(10); } foreach (DiscoveredPrinter printer in discoveryHandler.DiscoveredPrinters) { Console.WriteLine(printer); } Console.WriteLine($"Discovered {discoveryHandler.DiscoveredPrinters.Count} Link-OS™ printers."); }); }; View.AddSubview(testButton); } private class NetworkDiscoveryHandler : DiscoveryHandler { public void DiscoveryError(string message) { Console.WriteLine($"An error occurred during discovery: {message}."); DiscoveryComplete = true; } public void DiscoveryFinished() { DiscoveryComplete = true; } public void FoundPrinter(DiscoveredPrinter printer) { DiscoveredPrinters.Add(printer); } public bool DiscoveryComplete { get; private set; } = false; public List<DiscoveredPrinter> DiscoveredPrinters { get; } = new List<DiscoveredPrinter>(); } }