Skip to content

five-on-it / apps/client/src/renderer/latency / LatencySimulator

Class: LatencySimulator ​

Defined in: apps/client/src/renderer/latency.ts:21

Wraps a transport and adds rttMs / 2 of delay each way, and the loss of lossPercent of the frames that may be lost.

Implements ​

Constructors ​

Constructor ​

new LatencySimulator(inner, random?): LatencySimulator

Defined in: apps/client/src/renderer/latency.ts:33

Wraps inner; random draws the losses and the jitter (the page's own Math.random).

Parameters ​

inner ​

Transport

random? ​

() => number

Returns ​

LatencySimulator

Properties ​

lossPercent ​

lossPercent: number = 0

Defined in: apps/client/src/renderer/latency.ts:25

Simulated loss of the frames that may be lost, in percent (0 = none).


lost ​

lost: number = 0

Defined in: apps/client/src/renderer/latency.ts:27

Frames the simulated loss dropped so far.


rttMs ​

rttMs: number = 0

Defined in: apps/client/src/renderer/latency.ts:23

Simulated round-trip time in milliseconds (0 = pass-through).

Accessors ​

lossy ​

Get Signature ​

get lossy(): boolean

Defined in: apps/client/src/renderer/latency.ts:44

Whether frames may be lost: the transport's own, or the simulated loss.

Returns ​

boolean

Whether frames may be lost, duplicated or reordered (a WebRTC data channel without retransmits); absent or false for an ordered, reliable transport.

Implementation of ​

Transport.lossy

Methods ​

close() ​

close(): void

Defined in: apps/client/src/renderer/latency.ts:76

Closes the connection; the close listener fires on both ends.

Returns ​

void

Implementation of ​

Transport.close


onClose() ​

onClose(handler): void

Defined in: apps/client/src/renderer/latency.ts:72

Registers the single close listener.

Parameters ​

handler ​

() => void

Returns ​

void

Implementation of ​

Transport.onClose


onMessage() ​

onMessage(handler): void

Defined in: apps/client/src/renderer/latency.ts:68

Registers the single receiver of incoming frames.

Parameters ​

handler ​

(message) => void

Returns ​

void

Implementation of ​

Transport.onMessage


send() ​

send(channel, message): void

Defined in: apps/client/src/renderer/latency.ts:62

Sends one frame. unreliable frames may be dropped or reordered by a future transport; today every transport delivers both channels reliably and in order.

Parameters ​

channel ​

"reliable" | "unreliable"

message ​

TransportMessage

Returns ​

void

Implementation of ​

Transport.send