public class DiscoveryHandlerLinkOsOnly extends Object implements DiscoveryHandler
package test.zebra.sdk.discovery.examples;
import java.util.ArrayList;
import java.util.List;
import com.zebra.sdk.printer.discovery.DiscoveredPrinter;
import com.zebra.sdk.printer.discovery.DiscoveryException;
import com.zebra.sdk.printer.discovery.DiscoveryHandler;
import com.zebra.sdk.printer.discovery.DiscoveryHandlerLinkOsOnly;
import com.zebra.sdk.printer.discovery.NetworkDiscoverer;
public class DiscoveryHandlerLinkOsOnlyExample {
public static void main(String[] args) {
DiscoveryHandler discoveryHandler = new DiscoveryHandler() {
List<DiscoveredPrinter> printers = new ArrayList<DiscoveredPrinter>();
public void foundPrinter(DiscoveredPrinter printer) {
printers.add(printer);
}
public void discoveryFinished() {
for (DiscoveredPrinter printer : printers) {
System.out.println(printer);
}
System.out.println("Discovered " + printers.size() + " Link-OS(TM) printers.");
}
public void discoveryError(String message) {
System.out.println("An error occurred during discovery : " + message);
}
};
try {
System.out.println("Starting Link-OS(TM) printer discovery.");
NetworkDiscoverer.findPrinters(new DiscoveryHandlerLinkOsOnly(discoveryHandler));
} catch (DiscoveryException e) {
e.printStackTrace();
}
}
}
NetworkDiscoverer
Constructor and Description |
---|
DiscoveryHandlerLinkOsOnly(DiscoveryHandler internalDiscoveryHandler)
Creates a DiscoveryHandler which will only report back Link-OS™ printers.
|
Modifier and Type | Method and Description |
---|---|
void |
discoveryError(String message)
This method is invoked when there is an error during discovery.
|
void |
discoveryFinished()
This method is invoked when discovery is finished.
|
void |
foundPrinter(DiscoveredPrinter printer)
This method is invoked when a Link-OS™ printer has been discovered.
|
public DiscoveryHandlerLinkOsOnly(DiscoveryHandler internalDiscoveryHandler)
internalDiscoveryHandler
- base discovery handler for callbackspublic void foundPrinter(DiscoveredPrinter printer)
foundPrinter
in interface DiscoveryHandler
printer
- a discovered Link-OS™ printer.public void discoveryFinished()
discoveryFinished
in interface DiscoveryHandler
public void discoveryError(String message)
discoveryFinished()
will not be called if this method is invoked.discoveryError
in interface DiscoveryHandler
message
- the error message.
© 2015 ZIH Corp. All Rights Reserved.