Skip to main content

A caller for a method on the server.

TODO-DOC

Example

const method = new VOXELIZE.Method();

// Register the method caller with the network.
network.register(method);

// Call a method on the server.
method.call("my-method", { hello: "world" });

Implements​

Properties​

packets​

• packets: MessageProtocol<any, any, any, any>[] = []

An array of packets to be sent to the server. These packets will be sent to the server after every network.flush() call.

Implementation of​

NetIntercept.packets

Methods​

call​

▸ call(name, payload?): MessageProtocol<any, any, any, any>

Call a defined method on the server.

Parameters​

NameTypeDescription
namestringThe name of the method to call.
payloadanyThe JSON serializable payload to send to the server.

Returns​

MessageProtocol<any, any, any, any>

The queued packet. Callers that must know whether the command actually left the client can flush the network and then check the packet's absence from both this intercept's packets queue and Network.isPacketPendingSend.


confirm​

▸ confirm(name, payload?, options?): Object

Call a method and find out what the server did with it. The call goes out between two pings: the server handles one client's messages in order, so a reply about the call (UNHANDLED_METHOD_REPLY, METHOD_REJECTED_REPLY) lands between the two pongs, and a call that drew no reply by the second pong ran.

Needs this caller registered with the network, and goes out on the next flush like any call.

Parameters​

NameType
namestring
payloadany
optionsObject
options.timeoutMs?number

Returns​

Object

NameType
outcomePromise<MethodOutcome>
packetMessageProtocol<any, any, any, any>

onMessage​

▸ onMessage(message): void

Parameters​

NameType
messageMessageProtocol<any, any, any, any>

Returns​

void

Implementation of​

NetIntercept.onMessage