java.lang.Object
com.itemis.jscdlib.ScDaemonHandle
- All Implemented Interfaces:
AutoCloseable
Provides a convenient Java interface to SCDaemon functionality.
-
Nested Class Summary
Nested Classes -
Constructor Summary
ConstructorsConstructorDescriptionScDaemonHandle(ScDaemonNativeBridge bridge, JScdSocketDiscovery socketDiscovery) Create a new instance and initialize resources. -
Method Summary
-
Constructor Details
-
ScDaemonHandle
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:
closein interfaceAutoCloseable
-