Interface IOMethod


public interface IOMethod
Represents a single method than can be exposed by an 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 Type
    Method
    Description
    int
    The code identifying this method to the guest.
    void
    invoke(InputStream arguments, OutputStream results)
    Called to run this method.
    boolean
    When true, 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()
      When true, invocations of this method will be synchronized to the main thread.
      Returns:
      true when to be executed on main thread; false otherwise.
    • invoke

      void invoke(InputStream arguments, OutputStream results) throws Throwable
      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 arguments yields -1, as usual; implementations are responsible for validating that they got the arguments they need. Throwing EOFException, IllegalArgumentException or IllegalStateException tells the guest it called the method wrong; anything else is reported as an internal error. The readers on IOInputStream throw EOFException for 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.