0

I have built a small car robot using Raspberry Pi. The control for the robot is accessed via an apache webserver hosted on the Pi, which uses PHP to drive the motors based on user input. I plan to open this robot to the internet to allow anyone to control it, but my question is: Is there a way to control the amount of users connected to the webserver, as I would like only one person at a time to be able to control the bot?

1 Answers1

0

Place the functionality of your robot into one page. When someone accesses that page create a temporary file, such as temp.lock.

Check for creation of the temp.lock file when page is accessed, if temp.lock file exists, deny access to that page.

Once the user has closed the page, or a timeout occurs, delete the temp.lock file.

Creation of a tempfile:

$temp = tmpfile();
fwrite($temp, "writing to tempfile");
fseek($temp, 0);
echo fread($temp, 1024);
fclose($temp); // this removes the file

PHP:tmpfile
Daniweb.com

elePHPant
  • 21
  • 4