API Docs for:
Show:

Registry Class

Defined in: src/registry.js:37

Manages the registration of classes for consistent serialization/unserialization

Constructor

Registry

()

Defined in src/registry.js:37

Methods

addClass

(
  • klass
  • instance
)

Defined in src/registry.js:95

Register a class with Wasabi, allowing it to transmit instances of this class through a Connection

Parameters:

  • klass Function

    The constructor of the class to add

  • instance Wasabi

    The Wasabi instance to invoke the RPC through

addObject

(
  • obj
  • serial
)

Defined in src/registry.js:211

Register an instance of a klass

Parameters:

  • obj NetObject

    The object to add to the registry

  • serial Nunmber

    The serial number to assign to this object. If falsy, the nextSerialNumber will be used

getClass

()

Defined in src/registry.js:252

Get the function/constructor/klass represented by the given hash

getObject

()

Defined in src/registry.js:244

Get an instance of a klass by serial number

getRpc

()

Defined in src/registry.js:260

get the RPC function associated with the hash

hash

(
  • fn1
  • fn2
)
Number

Defined in src/registry.js:61

Return a unique hash from one or two functions suitable for entering into the registry's klass or rpc tables. Note that the supplied functions must have a valid name property

Parameters:

  • fn1 Function

    The first function to hash

  • fn2 Function

    The (optional) second function to hash

Returns:

Number:

The XOR hash of the characters of klass.prototype.constructor.name

mkRpc

(
  • klass
  • fn
  • serialize
  • instance
)
Function

Defined in src/registry.js:160

Create an RPC from the supplied procedure function and serialize function. instance must be a Wasabi instance

Parameters:

  • klass Function

    The klass this rpc is associated with, or false for static RPCs

  • fn Function

    The local function to call when the RPC is invoked on a remote host

  • serialize Function

    A serialize function describing the arguments used by this RPC

  • instance Wasabi

    The Wasabi instance to invoke this RPC through

Returns:

Function:

The function you should call remotely to invoke the RPC on a connection

removeObject

(
  • arg
)

Defined in src/registry.js:224

Remove an instance of a klass

Parameters:

  • arg NetObject | Number

    The object or serial number of an object to remove from the registry