Class RemoteStatusConnection

Object
com.zebra.sdk.comm.ConnectionA
com.zebra.sdk.comm.ConnectionStatusA
com.zebra.sdk.remote.comm.RemoteStatusConnection
All Implemented Interfaces:
Connection, ConnectionWithWriteLogging, StatusConnection, StatusConnectionWithWriteLogging

public class RemoteStatusConnection extends ConnectionStatusA
Establishes a status only Remote connection to a device.


package test.zebra.sdk.comm.examples;
 
 import com.zebra.sdk.comm.Connection;
 import com.zebra.sdk.comm.ConnectionException;
 import com.zebra.sdk.printer.SGD;
 import com.zebra.sdk.remote.comm.RemoteStatusConnection;
 
 public class RemoteStatusConnectionExample {
 
     // 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 RemoteStatusConnectionExample().sendJSONOverStatusChannel("myPrinterUUID");
     }
 
     private void sendJSONOverStatusChannel(String theIpAddress) throws ConnectionException {
         // Instantiate a remote status connection to the printer specified by UUID using the default Zebra Web
         // services port (11995).
         // Note: The printer must be connected to a server which is running a Zebra servlet instance.
         Connection thePrinterConn = new RemoteStatusConnection(theIpAddress);
 
         try {
             // Open the connection - physical connection is established here.
             thePrinterConn.open();
 
             // This sends down JSON to the status channel to retrieve the 'appl.name' setting
             String firmwareVersion = SGD.GET("appl.name", thePrinterConn);
 
             System.out.println("The firmware version is : " + firmwareVersion);
         } catch (ConnectionException e) {
             // Handle communications error here.
             e.printStackTrace();
         } finally {
             // Close the connection to release resources.
             thePrinterConn.close();
         }
     }
 }
 
  • Constructor Details

    • RemoteStatusConnection

      public RemoteStatusConnection(String uniqueId)
      Initializes a new instance of the RemoteStatusConnection class using the default Zebra Web services port (11995).
      This constructor will use the default timeouts for Connection.read(). The default timeout is a maximum of 5 seconds for any data to be received. If no more data is available after 1 second the read operation is assumed to be complete.
      To specify timeouts other than the defaults, use:
      RemoteStatusConnection(String, int, int, int)
      Parameters:
      uniqueId - the UUID of the device.
      See Also:
    • RemoteStatusConnection

      public RemoteStatusConnection(String uniqueId, int rmiServerPort)
      Initializes a new instance of the RemoteStatusConnection class using the specified rmiServerPort. This constructor will use the default timeouts for Connection.read(). The default timeout is a maximum of 5 seconds for any data to be received. If no more data is available after 1 second the read operation is assumed to be complete.
      To specify timeouts other than the defaults, use:
      RemoteStatusConnection(String, int, int, int)
      Parameters:
      uniqueId - the UUID of the device.
      rmiServerPort - the port the RMI server is running on.
    • RemoteStatusConnection

      public RemoteStatusConnection(String uniqueId, int rmiServerPort, int maxTimeoutForRead, int timeToWaitForMoreData)
      Initializes a new instance of the RemoteStatusConnection class using the specified rmiServerPort. This constructor will use the specified timeouts for Connection.read(). The timeout is a maximum of maxTimeoutForRead milliseconds for any data to be received. If no more data is available after timeToWaitForMoreData milliseconds the read operation is assumed to be complete.
      Parameters:
      uniqueId - the UUID of the device.
      rmiServerPort - the port the RMI server is running on.
      maxTimeoutForRead - the maximum time, in milliseconds, to wait for any data to be received.
      timeToWaitForMoreData - the maximum time, in milliseconds, to wait in-between reads after the initial read.
  • Method Details