Skip to content
mkind edited this page Mar 9, 2016 · 3 revisions

Adding Remote Functions

If you define a remote function you need to specify the argument types using ctypes.* and annotations. Don't worry, it's quite simple!

import ctypes

from splonecli.api.plugin import RemoteFunction


@RemoteFunction
def add(a: ctypes.c_int64, b: ctypes.c_int64):
  """Adds two numbers"""
  return a + b

That's it! Supportet types are: ctypes.c_bool, ctypes.c_byte, ctypes.c_uint64, ctypes.c_int64, ctypes.c_double, ctypes.c_char_p, ctypes.c_long (c_char_p represents a string).

** Make sure to import the files with @RemoteFunction decorators somewhere! The python interpreter can't guess where to look for these :)**

Whatever you return will be sent back as a result to the caller. If you raise a RemoteException the error code and message will also be sent to the caller. Other exceptions will be ignored.

Clone this wiki locally