Room
Index
Properties
Accessors
Methods
Properties
downloadSampleSize
latencySampleSize
The number of samples to use when calculating average latency.
pingDelay
The number of milliseconds to wait before sending a ping packet.
uploadSampleSize
Last N seconds to use when calculating average bytes uploaded per second.
Accessors
averageBytesDownloadedPerSecond
Returns the average bytes downloaded per second over the last N seconds.
Returns number
averageBytesUploadedPerSecond
Returns the average bytes uploaded per second over the last N seconds.
Returns number
averageLatency
Returns the average latency over the last N seconds.
Returns number
bytesDownloadedSinceLastSecond
Returns the number of bytes downloaded in the last second.
Returns number
bytesUploadedSinceLastSecond
Returns the number of bytes uploaded in the last second.
Returns number
closeReason
Returns the reason for the connection being closed.
Returns string
currentLatency
Latest recorded latency sample in milliseconds.
Returns number
id
Returns the ID of the room.
Returns string
localClientId
Returns the ID of the local client.
Returns number
totalBytesDownloaded
Returns the total number of bytes downloaded since the connection was established.
Returns number
totalBytesUploaded
Returns the total number of bytes uploaded since the connection was established.
Returns number
Methods
onClose
Registers a handler for when the connection is closed.
Parameters
callback: (e: Event) => void
The callback function that will be called when the connection is closed.
Returns void
onError
Registers a handler for when the server sends an error.
Parameters
callback: (error: string) => void
The callback function that will be called when the server sends an error.
Returns void
onMessage
Registers a handler for
eventParameters
event: string | number
Unique identifier for this event.
Using a
stringfor event ids is not recommended as it makes the network packet considerably bigger (2 bytes for length and an extra 2 bytes for every character in string).You may use any number from 0 to 255.
handler: MessageHandler
The MessageHandler function that will be called when this event is received.
Returns void
send
Sends a message to the server.
Parameters
event: string | number
Unique identifier for this event.
message: string | number | object | Buffer
The message to send.
Returns void
Last N seconds to use when calculating average bytes downloaded per second.