About the role of the PHP server as an intermediate transit station?

good evening, big gods. I have this need: the PHP server acts as a middleman to communicate between the mobile app end and the hardware device (roughly like this, some words may be unprofessional). In some cases, the app side and the hardware side take the initiative to call up the PHP interface to communicate through http. There is a situation (I am fascinated here) that requires the PHP server to actively communicate with the mobile phone and the device (that is, to actively tell the two ports what needs to be done), how to solve this requirement? What kind of technology needs to be used? Please give me some advice! Please


php actively communicates with mobile devices? So how did php find them?
feels the need to make a long connection. The mobile device first requests the server to pull the long connection, and then the server sends it. But php is not naturally suitable for long connections, so you can take a look at wheels such as swoole, or (if possible) replace them with stacks such as Node.js that are suitable for long connections.


this is actually PHP as the server, and App and hardware as the client, which can also be thought of as the data sender
. Then it is divided into two scenarios

.
  • non-instant messaging scenarios

    • for example, just some data is collected from hardware. If users on App take a look at it from time to time, they only need the php server to store the data in the database, and then check it when App calls the API request
  • Instant messaging scenarios, such as instant monitoring client data

    • Instant messaging scenarios can use HTTP polling or establishing socket persistent connections. Swoole is a very good choice for socket, especially for later swoole4.x. There is nothing to say about HTTP polling. Request data once every two or three seconds
Menu