Class RemoteDiscoverer

Object
com.zebra.sdk.remote.discovery.RemoteDiscoverer

public class RemoteDiscoverer extends Object
A class used to discover remote Link-OS printers connected via web sockets to a Zebra serlvet. There must be a server running a Zebra Web Service for this class to work.
If you want to discover locally connected IP printers, see NetworkDiscoverer

package test.zebra.sdk.comm.examples;
 
 import java.util.List;
 
 import com.zebra.sdk.comm.Connection;
 import com.zebra.sdk.comm.ConnectionException;
 import com.zebra.sdk.printer.ZebraPrinter;
 import com.zebra.sdk.printer.ZebraPrinterFactory;
 import com.zebra.sdk.printer.ZebraPrinterLanguageUnknownException;
 import com.zebra.sdk.printer.discovery.DiscoveredPrinter;
 import com.zebra.sdk.remote.comm.RemoteConnection;
 import com.zebra.sdk.remote.discovery.RemoteDiscoverer;
 
 public class RemoteDiscovererExample {
 
     // This example assumes Link-OS printers are connected via Web Sockets to a server which is running a Zebra servlet
     // instance.
     public static void main(String[] args) throws Exception {
         new RemoteDiscovererExample().listRemotePrinters();
         new RemoteDiscovererExample().printConfigLabelUsingDnsName("myPrinterUUID");
     }
 
     private void listRemotePrinters() {
         try {
             List<DiscoveredPrinter> connectedPrinters = RemoteDiscoverer.getConnectedPrinters();
             for (DiscoveredPrinter p : connectedPrinters) {
                 String serialNumber = p.getDiscoveryDataMap().get("SERIAL_NUMBER");
                 System.out.println("Serial number " + serialNumber);
             }
         } catch (ConnectionException e) {
             e.printStackTrace();
         }
     }
 
     private void printConfigLabelUsingDnsName(String theUniqueId) throws ConnectionException {
         Connection connection = new RemoteConnection(theUniqueId);
         try {
             connection.open();
             ZebraPrinter p = ZebraPrinterFactory.getInstance(connection);
             p.printConfigurationLabel();
         } catch (ConnectionException e) {
             e.printStackTrace();
         } catch (ZebraPrinterLanguageUnknownException e) {
             e.printStackTrace();
         } finally {
             connection.close();
         }
     }
 }
 
  • Method Details

    • getConnectedPrinters

      public static List<DiscoveredPrinter> getConnectedPrinters() throws ConnectionException
      Returns a list of remotely connected Zebra printers. This method assumes the Zebra Weblink servlet is running on the default Zebra Web Services port (11995).
      Returns:
      list of Link-OS printers currently connected via a web socket connection to the servlet.
      Throws:
      ConnectionException - if there is a problem connecting to the Zebra Weblink servlet.
      See Also:
    • getConnectedPrinters

      public static List<DiscoveredPrinter> getConnectedPrinters(int rmiServerPort) throws ConnectionException
      Returns a list of remotely connected Zebra printers. The Zebra Weblink servlet needs to be running on the specified rmiServerPort.
      Parameters:
      rmiServerPort - the port the RMI server is running on.
      Returns:
      list of Link-OS printers currently connected via a web socket connection to the servlet.
      Throws:
      ConnectionException - if there is a problem connecting to the Zebra Weblink servlet.
    • registerForConnections

      public static void registerForConnections(ConnectionHandlerI connectionHandler, int rmiServerPort) throws ConnectionException
      Register for connection events from the Zebra Weblink servlet.
      Parameters:
      connectionHandler - callback to receive connection events.
      rmiServerPort - the port the RMI server is running on.
      Throws:
      ConnectionException - if there is a problem connecting to the Zebra Weblink servlet.