Interface IOMethod
IODevice.
The easiest and hence recommended way of generating an implementation of this
interface is to use the ObjectDevice class.
This is the mid-level API targeting CP/M guests. Also see the high-level API equivalent for
Linux guests, RPCMethod.
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionintgetCode()The code identifying this method to the guest.voidinvoke(InputStream arguments, OutputStream results) Called to run this method.booleanWhentrue, invocations of this method will be synchronized to the main thread.
-
Method Details
-
getCode
int getCode()The code identifying this method to the guest.- Returns:
- the method code.
-
isSynchronized
boolean isSynchronized()Whentrue, invocations of this method will be synchronized to the main thread.- Returns:
truewhen to be executed on main thread;falseotherwise.
-
invoke
Called to run this method.Important: methods are expected to not irrevocably corrupt internal state, even when they throw an exception. As such, implementations should perform internal error handling to prevent state corruption and only throw exceptions to communicate that an error happened during the invocation.
Reading past the end of
argumentsyields-1, as usual; implementations are responsible for validating that they got the arguments they need. ThrowingEOFException,IllegalArgumentExceptionorIllegalStateExceptiontells the guest it called the method wrong; anything else is reported as an internal error. The readers onIOInputStreamthrowEOFExceptionfor you.- Parameters:
arguments- the bytes the guest wrote for this call.results- the bytes to hand back to the guest.- Throws:
Throwable- if the parameters did not match or something inside the method caused an exception. The caller is responsible for catching these and passing them on appropriately.
-