How to restrict a webpage to only one user(Browser Tab)
Specify a variable like serial_usage which has an initial value False. When a new client connected to your WebSocket server, check the serial_usage variable. If serial port is not being used at that moment (serial_usage == False), make the connection happen, set serial_usage True. When the client disconnects, set serial_usage variable False. If serial port is being used by another client (serial_usage == True), you can show an error page and prevent the new connection.
I am building a Python Flask webpage that uses websockets to connect to a single serial port(pySerial).
The webpage will collect a list of commands to be executed(user input) and send that to the serial port via websockets.
The problem I am facing is that as soon as the webpage has been opened multiple times commands can be sent at any time and might get run out of order.