javascriptpythonhtmlflask-socketio

How do I use SocketIO to store and send multiple pieces of data at once?


I am making a Fast Food Management system and I need to find a way to send order information from a client app to a main server, for it to be shown in a similar way to that in McDonald's, with the order number and status displayed. The front end is not an issue, as I want buttons to have certain ID's that correlate to food items, however I am struggling to find a way to store the order input for it to all be sent as a message to the main server. I was thinking of an invisible input box for data to be added into it when the buttons are pressed but im sure theres a more efficient way.

I am currently attempting to set an invisible text box that data can be appended to, but I feel as there is a better way, as my end goal is for the order to be stored along with an allocated order number in a SQL Database.


Solution

  • The answer is that you should establish a communication protocol that you use within sockets/SocketsIO. Myself, I did this using json, but I think it would be just about as easy to do this in XML.

    Example:

    {
      type:1, //this is a system message, for example.
              //You types for sending text messages, different kinds of data, etc
      msg: ...,
      extra: ...
    }