Skip to content

five-on-it / packages/protocol/src/snapshot-acked / AckedEncoder

Class: AckedEncoder ​

Defined in: packages/protocol/src/snapshot-acked.ts:161

One client's side of the acked snapshots on the server: what it holds after each frame, and its acknowledgements.

Constructors ​

Constructor ​

new AckedEncoder(): AckedEncoder

Returns ​

AckedEncoder

Properties ​

keyframes ​

keyframes: number = 0

Defined in: packages/protocol/src/snapshot-acked.ts:173

Keyframes sent: frames with no acknowledged base.

Accessors ​

baseTick ​

Get Signature ​

get baseTick(): number | undefined

Defined in: packages/protocol/src/snapshot-acked.ts:212

The tick of the acknowledged frame the next one goes onto; undefined for a keyframe.

Returns ​

number | undefined


eventsHeld ​

Get Signature ​

get eventsHeld(): number

Defined in: packages/protocol/src/snapshot-acked.ts:207

How many events wait for an acknowledgement.

Returns ​

number


framesHeld ​

Get Signature ​

get framesHeld(): number

Defined in: packages/protocol/src/snapshot-acked.ts:194

How many frames the server keeps for the client (at most SENT_RING).

Returns ​

number


holding ​

Get Signature ​

get holding(): number

Defined in: packages/protocol/src/snapshot-acked.ts:184

How many entities the client holds.

Returns ​

number


inFlight ​

Get Signature ​

get inFlight(): number

Defined in: packages/protocol/src/snapshot-acked.ts:202

How many frames were sent since the one the client acknowledged (all of them before an acknowledgement): what is in flight, or what a client behind has not read yet.

Returns ​

number

Methods ​

ack() ​

ack(tick): void

Defined in: packages/protocol/src/snapshot-acked.ts:221

The client applied the frame of tick: the next frames go onto it (unless a newer one was acknowledged already), the frames before it are forgotten, and its events are settled. An acknowledgement of a frame the server no longer keeps changes nothing.

Parameters ​

tick ​

number

Returns ​

void


encode() ​

encode(arena, frame): Uint8Array

Defined in: packages/protocol/src/snapshot-acked.ts:235

The next frame for the client: what turns the acknowledged frame's state into this one's.

Parameters ​

arena ​

EntityArena

frame ​

DeltaFrame

Returns ​

Uint8Array


has() ​

has(eid): boolean

Defined in: packages/protocol/src/snapshot-acked.ts:189

Whether the client holds an entity after the last frame sent.

Parameters ​

eid ​

number

Returns ​

boolean


reset() ​

reset(): void

Defined in: packages/protocol/src/snapshot-acked.ts:176

Forgets everything: the next frame is a keyframe of what the client sees now (a client switching to the acked snapshots).

Returns ​

void