NetMessages
The NetMessages namespace provides helpers for sending, receiving, and intercepting network messages.
Type Aliases
Callback<T>(obj: T) => boolean | void
Defines a mutable callback signature used by NetMessages registration APIs.
CallbackReadOnly<T>(obj: T) => void
Defines a read-only callback signature used by NetMessages registration APIs.
Functions
Send<T>(obj: T, msgName: string, reliable?: boolean)void
Force client to send a passed message.
objT - The object to receive the message.msgNamestring - The name of the message to receive.reliableboolean (optional) - Whether the message should be sent reliably. Default is true.
Recv<T>(obj: T, msgName: string, reliable?: boolean)void
Force client to receive a passed message.
objT - The object to receive the message.msgNamestring - The name of the message to receive.reliableboolean (optional) - Whether the message should be sent reliably. Default is true.
RegisterRecv<T>(msgName: string, callback: Callback<T>)void
Register a callback to be called when a message is received. Message will be received on the next main loop update.
msgNamestring - The network message name.callbackCallback<T> - The callback function to register.
RegisterRecvReadOnly<T>(msgName: string, callback: CallbackReadOnly<T>)void
Register a callback to be called when a message is received. Message can be already received.
msgNamestring - The network message name.callbackCallbackReadOnly<T> - The callback function to register.
UnregisterRecv<T>(callback: Callback<T>)void
Unregisters a previously registered receive callback.
callbackCallback<T> - The callback function to register.
UnregisterRecvReadOnly<T>(callback: Callback<T>)void
Unregisters a previously registered read-only receive callback.
callbackCallback<T> - The callback function to register.
RegisterSend<T>(msgName: string, callback: Callback<T>)void
Register a callback to be called when a message is sent. Message will be sent on the next main loop update.
msgNamestring - The network message name.callbackCallback<T> - The callback function to register.
RegisterSendReadOnly<T>(msgName: string, callback: CallbackReadOnly<T>)void
Register a callback to be called when a message is sent. Message can be already sent.
msgNamestring - The network message name.callbackCallbackReadOnly<T> - The callback function to register.
UnregisterSend<T>(callback: Callback<T>)void
Unregisters a previously registered send callback.
callbackCallback<T> - The callback function to register.
UnregisterSendReadOnly<T>(callback: Callback<T>)void
Unregisters a previously registered read-only send callback.
callbackCallback<T> - The callback function to register.
ToDataView(data: string)DataView
Converts a string payload into a DataView that can be used with NetMessages APIs.
datastring - The raw payload data.
Returned:
- DataView - The result of the call.
FromDataView(data: DataView)string
Converts a DataView payload back into its string representation.
dataDataView - The raw payload data.
Returned:
- string - The result of the call.