Reputation: 9855
I'ts not a coding question so apologies if this is in the wrong forum, but how do sites such as https://lightsaber.withgoogle.com/ work? How does the site know the user is on the page with their phone? I've seen a few of these as of late and I'm at a loss as too how they're built...
Upvotes: 0
Views: 89
Reputation: 8233
It's not a coding question, you pointed it right.
But this is just what we can call Real time web, featuring technologies as NodeJS, Socket.io, etc. I played with this for fun, but I don't know any other technologies that offers the same features (there are some, it's just I don't know).
How does it work ?
To go a bit deeper :
So basically, the Google light saber exeprience can be see like this :
Mobile (send position x,y,z) --> Server (get mobile position and broadcast it) --> Desktop (get mobile position from server and apply changes on the view)
I talked about Node and Socket.io because it makes this kind of experience really simple. I mean: really.
Upvotes: 5
Reputation: 4683
This has to do with the link that the page offers. The first person who navigates to the generated link with their mobile phone is the one the site is going to "connect" with.
When you visit the generated link with your phone, that (mobile) page sends a signal to the original page (by some means, like with websockets or just database fiddling) which generated the link, that someone has navigated to the generated link with their phone. After that it's just the matter of what to do next.
Simplified:
A
generate a link to a page B
A
wait until generated page B
signals that someone has navigated to itA
(and B
) do somethingUpvotes: 1