new SnapshotHistory(cap)
This holds a limited history of snapshots received from
the server. The snapshots are organized by the order
received, and hold the current time when they were
received.
Parameters:
Name | Type | Argument | Description |
---|---|---|---|
cap |
number |
<optional> |
Maximum number of entries on the history. The default value is 10. |
- Source:
Members
-
<private> cap :number
-
Maximum length of the history.
Type:
- number
- Source:
-
<private> history :!Array.<!Grape2D.Snapshot>
-
List with the history record.
Type:
- !Array.<!Grape2D.Snapshot>
- Source:
Methods
-
add(snapshot)
-
Adds a snapshot to the history. Discards the older one if it has reached the entry limit.
Parameters:
Name Type Description snapshot
Grape2D.Snapshot Snapshot received. - Source:
-
getAfter(time) → {Grape2D.Snapshot}
-
Gets the snapshot received immediately after a given time.
Parameters:
Name Type Description time
number Reference time, in milliseconds. - Source:
Returns:
A string if it has found a valid snapshot after the time, null otherwise.- Type
- Grape2D.Snapshot
-
getBefore(time) → {Grape2D.Snapshot}
-
Gets the snapshot received immediately before a given time.
Parameters:
Name Type Description time
number Reference time, in milliseconds. - Source:
Returns:
A string if it has found a valid snapshot before the time, null otherwise.- Type
- Grape2D.Snapshot
-
getCap() → {number}
-
Gets the limit of snapshots recorded.
- Source:
Returns:
Maximum number of snapshots that can be stored.- Type
- number
-
getHistory() → {!Array.<!Grape2D.Snapshot>}
-
Gets the history list.
- Source:
Returns:
Snapshot history record.- Type
- !Array.<!Grape2D.Snapshot>
-
setCap(cap)
-
Sets the limit of snapshots recorded. If the limit is lower than the previous one, the record is adjusted to the correct length if needed be.
Parameters:
Name Type Description cap
number Maximum number of snapshots that can be stored. - Source: