diff --git a/client/players/PlayerHandler.js b/client/players/PlayerHandler.js index 57af1988..5821aee1 100644 --- a/client/players/PlayerHandler.js +++ b/client/players/PlayerHandler.js @@ -281,6 +281,10 @@ export default class PlayerHandler { } } + /** + * First sync happens after 20 seconds + * subsequent syncs happen every 10 seconds + */ startPlayInterval() { clearInterval(this.playInterval) let lastTick = Date.now() @@ -293,7 +297,7 @@ export default class PlayerHandler { const exactTimeElapsed = ((Date.now() - lastTick) / 1000) lastTick = Date.now() this.listeningTimeSinceSync += exactTimeElapsed - const TimeToWaitBeforeSync = this.lastSyncTime > 0 ? 5 : 20 + const TimeToWaitBeforeSync = this.lastSyncTime > 0 ? 10 : 20 if (this.listeningTimeSinceSync >= TimeToWaitBeforeSync) { this.sendProgressSync(currentTime) } @@ -315,7 +319,7 @@ export default class PlayerHandler { } this.listeningTimeSinceSync = 0 this.lastSyncTime = 0 - return this.ctx.$axios.$post(`/api/session/${this.currentSessionId}/close`, syncData, { timeout: 1000 }).catch((error) => { + return this.ctx.$axios.$post(`/api/session/${this.currentSessionId}/close`, syncData, { timeout: 4000 }).catch((error) => { console.error('Failed to close session', error) }) } @@ -335,7 +339,7 @@ export default class PlayerHandler { } this.listeningTimeSinceSync = 0 - this.ctx.$axios.$post(`/api/session/${this.currentSessionId}/sync`, syncData, { timeout: 3000 }).then(() => { + this.ctx.$axios.$post(`/api/session/${this.currentSessionId}/sync`, syncData, { timeout: 6000 }).then(() => { this.failedProgressSyncs = 0 }).catch((error) => { console.error('Failed to update session progress', error)