Interface HelperTransport
- All Known Implementing Classes:
NativeSubprocessTransport
public interface HelperTransport
The abstraction over the cn1-ble-helper child process's standard
I/O. HelperBleBackend speaks the line-delimited JSON protocol
through this seam only, so a host that has no operating-system process API
(the native Windows/Linux ports, which reach the subprocess through a
native bridge) can supply its own implementation, while the JavaSE
simulator supplies a subprocess-backed one.
All methods are called from at most one reader thread and the caller
thread; implementations must make readLine()/writeLine(String)
and close()/isAlive() safe for that pairing.
-
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Releases the transport and terminates the child process.booleanisAlive()True while the child process is running.readLine()Reads one line of the helper's standard output, blocking until a line is available.voidLaunches the helper.voidWrites one command line to the helper's standard input.
-
Method Details
-
start
Launches the helper.commandis the launch command line (the resolved helper binary path, optionally with arguments). A transport that was pre-configured with its own command by its factory may ignore anullargument and launch that instead.- Parameters:
command- the launch command line, ornullto use the transport's pre-configured command- Throws:
IOException- when the child process cannot be started
-
readLine
Reads one line of the helper's standard output, blocking until a line is available.- Returns:
- the next line without its terminator, or
nullat end of stream (the helper closed stdout / exited) - Throws:
IOException- when the pipe fails
-
writeLine
Writes one command line to the helper's standard input. The line terminator is appended by the transport and the stream is flushed.- Parameters:
line- the single-line JSON command, without a terminator- Throws:
IOException- when the pipe fails
-
close
void close()Releases the transport and terminates the child process. -
isAlive
boolean isAlive()True while the child process is running.
-