Skip to content
On this page

Class: NetworkListener ​

WebSGNetworking.NetworkListener

A listener for receiving network messages. The receive method should be called once per frame to drain the listener's internal message queue. When done with the listener, the close method should be called to free the listener's resources.

Table of contents ​

Constructors ​

Methods ​

Constructors ​

constructor ​

• new NetworkListener()

Methods ​

close ​

▸ close(): undefined

Closes the listener and frees its resources.

Returns ​

undefined

Defined in ​

websg.d.ts:2538


receive ​

▸ receive(buffer?): NetworkMessageIterator

This method returns an iterator that can be used to iterate over inbound network messages.

Parameters ​

NameTypeDescription
buffer?ArrayBufferAn optional buffer to use when reading network messages. This should be at least the size of the largest network message you intend to receive. If not provided, the buffer will be created internally.

Returns ​

NetworkMessageIterator

Defined in ​

websg.d.ts:2533