Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clients should not broadcast currentTime updates when they are not the player #14

Open
JoshuaKGoldberg opened this issue Sep 1, 2020 · 0 comments
Labels
area: game runtime Improvements to the core game experience. good first issue You can do this as a way to learn about the code! ❤ status: blocked Other work must be completed before this is tackled. type: cleanup Improving the structural quality of code or runtime smoothness/performance.

Comments

@JoshuaKGoldberg
Copy link
Collaborator

JoshuaKGoldberg commented Sep 1, 2020

Following #9: right now, useTimeSynchronization always sends video time updates to the server, no matter what:

useInterval(() => {
emitRoomData({
currentTime: videoElement.currentTime,
});
}, videoElementSyncInterval);

However, the server only cares about updates from room.player:

// Ignore currentTime updates from any client who didn't click the play button.
// This is a somewhat arbitrary measure to stop "currentTime battles", wherein
// two clients go back and forth sending vastly different times to each other.
currentTime:
newPlayer === person.id
? data.currentTime ?? room.data.currentTime
: room.data.currentTime,

It's a waste of bandwidth for the client to constantly be sending currentTime updates if they've received a notice of room data from the server that includes someone else's ID as the player. Since the server (once #13 is resolved) informs clients there is no more player when the player leaves, clients would start broadcasting their time again when needed.

Proposal: a client should only broadcast its currentTime if its ID matches the room data's player.

Sub-proposal: once this and #13 are in, make the frequency of currentTime updates something like 100 instead of the current 500, to take advantage of the reduced spam sent to the server.

(Blocked on #13 being resolved)

@JoshuaKGoldberg JoshuaKGoldberg added status: blocked Other work must be completed before this is tackled. area: game runtime Improvements to the core game experience. type: cleanup Improving the structural quality of code or runtime smoothness/performance. good first issue You can do this as a way to learn about the code! ❤ labels Sep 1, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: game runtime Improvements to the core game experience. good first issue You can do this as a way to learn about the code! ❤ status: blocked Other work must be completed before this is tackled. type: cleanup Improving the structural quality of code or runtime smoothness/performance.
Projects
None yet
Development

No branches or pull requests

1 participant