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

background service web worker #14

Open
4 tasks
svub opened this issue Feb 22, 2023 · 1 comment
Open
4 tasks

background service web worker #14

svub opened this issue Feb 22, 2023 · 1 comment

Comments

@svub
Copy link
Owner

svub commented Feb 22, 2023

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.
@svub svub added this to the minimal functionality milestone Feb 22, 2023
@ltfschoen
Copy link

ltfschoen commented Feb 24, 2023

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants