Registry Class
Manages the registration of classes for consistent serialization/unserialization
Constructor
Registry
()
Methods
addClass
-
klass
-
instance
Register a class with Wasabi, allowing it to transmit instances of this class through a Connection
Parameters:
-
klass
FunctionThe constructor of the class to add
-
instance
WasabiThe Wasabi instance to invoke the RPC through
addObject
-
obj
-
serial
Register an instance of a klass
Parameters:
-
obj
NetObjectThe object to add to the registry
-
serial
NunmberThe serial number to assign to this object. If falsy, the nextSerialNumber will be used
getClass
()
Get the function/constructor/klass represented by the given hash
getObject
()
Get an instance of a klass by serial number
getRpc
()
get the RPC function associated with the hash
hash
-
fn1
-
fn2
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
FunctionThe first function to hash
-
fn2
FunctionThe (optional) second function to hash
Returns:
The XOR hash of the characters of klass.prototype.constructor.name
mkRpc
-
klass
-
fn
-
serialize
-
instance
Create an RPC from the supplied procedure function and serialize
function. instance
must be a Wasabi
instance
Parameters:
-
klass
FunctionThe klass this rpc is associated with, or
false
for static RPCs -
fn
FunctionThe local function to call when the RPC is invoked on a remote host
-
serialize
FunctionA serialize function describing the arguments used by this RPC
-
instance
WasabiThe Wasabi instance to invoke this RPC through
Returns:
The function you should call remotely to invoke the RPC on a connection
removeObject
-
arg
Remove an instance of a klass
Parameters:
-
arg
NetObject | NumberThe object or serial number of an object to remove from the registry