Push a change to the server, or stash it locally if we're offline
(change: RecordsDiff<any>)
| 847 | |
| 848 | /** Push a change to the server, or stash it locally if we're offline */ |
| 849 | private push(change: RecordsDiff<any>) { |
| 850 | this.debug('push', change) |
| 851 | squashRecordDiffsMutable(this.speculativeChanges, [change]) |
| 852 | // in offline mode, we only accumulate in speculativeChanges |
| 853 | if (!this.isConnectedToRoom) return |
| 854 | if (!this.unsentChanges.nextDiff) { |
| 855 | this.unsentChanges.nextDiff = { added: {} as any, updated: {} as any, removed: {} as any } |
| 856 | } |
| 857 | // records are immutable, so sharing their references with `change` is fine — the |
| 858 | // squash gives nextDiff its own containers and tuples without deep-cloning records |
| 859 | squashRecordDiffsMutable(this.unsentChanges.nextDiff, [change]) |
| 860 | this.sendUnsentChanges() |
| 861 | } |
| 862 | |
| 863 | /** Get the target FPS for network operations based on presence mode */ |
| 864 | private getSyncFps(): number { |