So I have a stopwatch built and what I'm trying to do is "share" the same stopwatch between 2 or more computers while keeping functionality. What I mean by this is say I start then stop the stopwatch on my computer (pc1) and it lands on 0:01:43, a different computer (pc2) which the stopwatch is shared with stopped and started in real time and was also on 0:01:43, and if I start and stop it on pc2 then the time would be reflected on pc1. How can I code this kind of functionality with JavaScript and a WebRTC api?
Asked
Active
Viewed 88 times
1 Answers
1
You can't share an HTML element between multiple computers / browsers.
What you CAN do is share data either by having a back-end store the state OR by using p2p. See How can I make a browser to browser (peer to peer) connection?
One for sure part of your state would be the UTC timestamp when the stopwatch started.

JFord
- 126
- 1
- 9
-
Thank you for the response! I will definitely check that out. – mmcccall0813 Jan 29 '19 at 18:26
-
1One word of warning is that with P2P you won't have a single-source of truth for your data and will have to find a way to keep the state for each peer in sync. – JFord Jan 29 '19 at 18:30