Skip to main content

VrpcAdapter

API reference · Documentation

Classes​

VrpcAdapter

Generates an adapter layer for existing code and enables further VRPC-based communication.

Typedefs​

MetaData : Object.<String, Func>

Associates meta data to any function

Func
Param : Object
Callback : Object
Ret : Object

VrpcAdapter​

Generates an adapter layer for existing code and enables further VRPC-based communication.

Kind: global class


"create"​

Event 'create'

Emitted on creation of shared instance

Kind: event emitted by VrpcAdapter
Properties

NameTypeDescription
classNameStringThe class name of the create instance
instanceStringThe instance name
argsArray.<Any>The constructor arguments

"beforeDelete"​

Event 'beforeDelete'

Emitted when a deletion through the agent begins, while the instance can still be reached

Kind: event emitted by VrpcAdapter
Properties

NameTypeDescription
classNameStringThe class name of the instance
instanceStringThe instance name

"delete"​

Event 'delete'

Emitted once an instance was deleted through the agent (a client's delete, or an isolated instance whose owner went)

Kind: event emitted by VrpcAdapter
Properties

NameTypeDescription
classNameStringThe class name of the deleted instance
instanceStringThe instance name

"disposeFailed"​

Event 'disposeFailed'

Emitted when the dispose method of a deleted instance throws, rejects or does not settle within VrpcAdapter.DISPOSE_TIMEOUT. The instance is gone regardless.

Kind: event emitted by VrpcAdapter
Properties

NameTypeDescription
classNameStringThe class name of the deleted instance
instanceStringThe instance name
errorErrorWhat went wrong

"releaseFailed"​

Event 'releaseFailed'

Emitted when the release of an event registration threw or rejected; the registration is gone anyway

Kind: event emitted by VrpcAdapter
Properties

NameTypeDescription
contextStringThe instance (or class) of the registration
functionStringThe event function
argsArray.<Any>Its arguments, without handlers
errorErrorWhat went wrong

"greetFailed"​

Event 'greetFailed'

Emitted when a registration's greeting threw or rejected; the subscriber stays subscribed

Kind: event emitted by VrpcAdapter
Properties

NameTypeDescription
contextStringThe instance (or class) of the registration
functionStringThe event function
argsArray.<Any>Its arguments, without handlers
errorErrorWhat went wrong

VrpcAdapter.addPluginPath(dirPath, [maxLevel])​

Automatically requires .js files for auto-registration.

Kind: static method of VrpcAdapter
Params

  • dirPath String - Relative path to start the auto-registration from
  • [maxLevel] Number - Maximum search depth (default: unlimited)

VrpcAdapter.register(code, [options])​

Registers existing code and makes it (remotely) callable

Kind: static method of VrpcAdapter
Params

  • code Any - Existing code to be registered, can be a class or function object or a relative path to a module
  • [options] Object
    • [.onlyPublic] Boolean = true - If true, only registers public functions: none whose name begins with an underscore, and - when the JSDoc is read - none tagged @private or @access private
    • [.withNew] Boolean = true - If true, class will be constructed using the new operator
    • [.schema] Object = - If provided is used to validate ctor parameters (only works if registered code reflects a single class)
    • [.jsdocPath] String - if provided, parses documentation and provides it as meta information; a code given by path has its JSDoc read without

NOTE: This function currently only supports registration of classes (either when provided as object or when exported on the provided module path)


VrpcAdapter.registerInstance(obj, options)​

Registers an existing instance and make it (remotely) callable

Kind: static method of VrpcAdapter
Params

  • obj Object - The instance to be registered
  • options Object
    • .className String - Class name of the instance
    • .instance String - Name of the instance
    • [.onlyPublic] Boolean = true - If true, only registers public functions: none whose name begins with an underscore, and - when the JSDoc is read - none tagged @private or @access private
    • [.jsdocPath] String - if provided, parses documentation and provides it as meta information

VrpcAdapter.create(options) ⇒ Object​

Creates a new instance

Kind: static method of VrpcAdapter
Returns: Object - The real instance (not a proxy!)
Params

  • options Object
    • .className String - Name of the class which should be instantiated
    • [.instance] String - Name of the created instance. If not provided an id will be generated
    • [.args] Array - Positional arguments for the constructor call
    • [.isIsolated] bool = false - If true the created instance will be visible only to the client who created it

VrpcAdapter.delete(instance) ⇒ Boolean​

Deletes an instance: its name is free at once, the adapter takes back every listener it attached, and the object releases what it runs through its [Symbol.asyncDispose] or [Symbol.dispose] method, which runs in the background here (a remote delete answers once it settled).

Kind: static method of VrpcAdapter
Returns: Boolean - True in case of success, false otherwise
Params

  • instance String | Object - Instance (name or object itself) to be deleted

VrpcAdapter.getInstance(instance) ⇒ Object​

Retrieves an existing instance by name

Kind: static method of VrpcAdapter
Returns: Object - The real instance (not a proxy!)
Params

  • instance String - Name of the instance to be acquired

VrpcAdapter.getAvailableClasses() ⇒ Array.<String>​

Retrieves an array of all available classes (names only)

Kind: static method of VrpcAdapter
Returns: Array.<String> - Array of class names


VrpcAdapter.getAvailableInstances(className) ⇒ Array.<String>​

Provides the names of all currently running instances.

Kind: static method of VrpcAdapter
Returns: Array.<String> - Array of instance names
Params

  • className String - Name of class to retrieve the instances for

VrpcAdapter.on(eventName, listener)​

Listens to an event of the adapter: create, beforeDelete, delete, disposeFailed, releaseFailed or greetFailed

Kind: static method of VrpcAdapter
Params

  • eventName String - The event
  • listener function - Called with the event's payload

MetaData : Object.<String, Func>​

Associates meta data to any function

Kind: global typedef


Func​

Kind: global typedef
Params

  • description String - Function description
  • params Array.<Param> - Array of parameter details in order of signature
  • ret Ret - Object associating further information to return value

Param : Object​

Kind: global typedef
Params

  • name String - Parameter name
  • optional Boolean - Whether parameter is optional
  • description String - Parameter description
  • [type] String - Parameter type
  • [default] Any - The default to be injected when not provided
  • [callback] Callback - The signature of a function-typed parameter, when a @callback typedef of that name documents it

Callback : Object​

Kind: global typedef
Params

  • name String - Typedef name (the parameter's type)
  • description String - Callback description
  • params Array.<Param> - The arguments the function is called with

Ret : Object​

Kind: global typedef
Params

  • description String - Return value description
  • [type] String - Return value type