I have an Imp project that will be controlled from a publicly accessible website. There’s a possibility that two or more web clients/visitors will attempt to issue commands to the Imp at the same time. What I would like to have is a round-robin access system, so that each time a web client/visitor loads the page, they’re given a minute of exclusive control of the Imp. If a second visitor loads the page while another visitor is in control, they would be queued. When a visitor’s time expires, they’re pushed to the back of the queue, control is transferred to the the next waiting client, and so on. And when visitors leave, they’d be removed from the queue.
Is anyone familiar with an existing framework or solution that provides this functionality?
Awesome - got any agent code you want to share?
No secret sauce in my agent code, not dissimilar to your SnackBot agent code. The Imp still acts as if it’s a single-user device. The Python server will have the round-robin code and handle the request bridging to the Imp.
Despite the extra layer, I like the idea of hiding the Imp agent’s public endpoint, since it won’t be (viewable) in the client side code…
I’ll share the Python code once the project is over (it’s for an artist client, the piece is going into a public art gallery for a month, people from all over the world will be manipulating his sculpture thanks to the power of Imp
Could a user still hijack it by making calls directly to the agent URL, or are you doing a bit of security in the agent?
I’ve done something similar with PHP/MySQL and JQuery Mobile …
With PHP, I’ve hidden the agent URL in the server-side scripting. Also, nothing gets executed with those scripts unless the user is logged-in (PHP SESSION is active). Only one person at a time can be ‘active’ with my multi-user script. The others are waiting in a queue for the ‘active’ person to finish their turn (2 minutes).
So I use 3 states:
- lurking. not logged in and not waiting.
- logged-in, but not ‘active’ (waiting in the queue).
- logged-in and ‘active’ (this person is in control of the imp).
The PHP script that posts to the imp only executes for the ‘active’ person.
People that view the HTML source will see the JQuery calls to the PHP script that posts to the imp, but not the imp URL. Unless there is a PHP SESSION set for them, they can’t do anything with it.