Open svub opened 1 year ago
For users using a web browser on the same device consider using a SharedWorker
incase the user had multiple browser windows open https://developer.mozilla.org/en-US/docs/Web/API/SharedWorker rather than just a standard web workerWorker
?
But since the user might be accessing the app on multiple devices at the same time (web browser X on device A, web browser Y on device A, android app on device B), i think we'd need to setup a server, where each frontend checks the device location using HTML5 Geolocation API and sends it to the server which is where we'd update the latest location and check if their location and that of other relevant users has changed.
I'm not sure how to handle if a different location is sent from different devices that they're logged in to, maybe in settings they configure which device(s) they want use to share their location, and we'd otherwise have to detect which device is most likely active by prioritising the device where latest UI interaction has occurred, and we'd store that server-side.
On the server-side we'd allow sufficient time using setInterval
for each of the possible devices that they've registered that they could be using to have shared their latest location from) and after that interval we'd respond as to whether their location has changed or if any of their contacts is nearby, by emitting the data broadcasting it to each client over a websockets, and that'd be received by a websockets connection on each client. i'm not sure whether we'd use 'polling' or 'websockets' for the transport (i.e. http://localhost:3000/socket.io/?EIO=4&transport=polling) https://socket.io/docs/v3/client-initialization/.
Then we'd integrate data received on the client-side via websockets with the client-side web workers (i.e. SharedWorker
) like shown here https://developer.mozilla.org/en-US/docs/Web/API/SharedWorker for web browser implementations
I also think we'd need to setup a server since it might reduce the risk of exposing their location and where their data is being stored.
basic web worker that gets triggered regularly (settings).
[ ] starts sync controller
[ ] checks for location*
[ ] notifies if user location seems to have changed*
[ ] notifies user if contact is close by*
if configured to do so in settings. v1 can use simple config file.