Class ScDaemonHandle

java.lang.Object
com.itemis.jscdlib.ScDaemonHandle
All Implemented Interfaces:
AutoCloseable

public final class ScDaemonHandle extends Object implements AutoCloseable
Provides a convenient Java interface to SCDaemon functionality.
  • Constructor Details

    • ScDaemonHandle

      public ScDaemonHandle(ScDaemonNativeBridge bridge, JScdSocketDiscovery socketDiscovery)
      Create a new instance and initialize resources. Be aware that after construction, this object holds resources, so it might be a bad idea to construct many instances of this object in advance.
      Parameters:
      bridge - OS dependent implementation to use when calling low level library functions.
      socketDiscovery - Used to determine the scdaemon socket file to use for communication to the daemon.
  • Method Details

    • sendCommand

      public void sendCommand(String command, Consumer<String> responseConsumer, Consumer<String> statusConsumer)

      Send a command to the scdaemon.

      Be aware that for some commands, scdaemon uses the response callback and for others the status callback.

      Be also aware that consumers are called synchronously, i. e. this method won't return if one of the consumers blocks.

      Parameters:
      command - The command to send.
      responseConsumer - Called when scdaemon responds with data.
      statusConsumer - Called when scdaemon responds with status lines.
    • close

      public void close()
      Release resources hold by this instance. When this method returns, this instance must not be used anymore.
      Specified by:
      close in interface AutoCloseable