Recently, the project needs to synchronize messages from the server to the mobile end. What is the best solution? I first came up with two solutions: the first one: ajax round-robin (obviously not a good method, because the server message is an unknown message. If the round-robin is always maintained, even if... recently, the project needs to synchronize messages from the server to the mobile end. What is the best solution? I first came up with two solutions:
First: ajax round-robin (obviously not a good method, because the server message is unknown. If the round-robin is maintained, even if the interval is several seconds, the mobile end does not end the round-robin operation, just like an infinite loop without terminating the operation)
Type 2: Use websocket to establish a persistent connection where the business needs to be updated in real time. google has a lot of information and many people on the internet suggest using Ratchet. The problem is, has anyone used this tool library? What are their similarities and differences with domestic workman ?? How to select these two tools...
By the way, the important thing is that the project is developed based on CI3, so the compatibility with ci3.
The following are some of my key information:
Http://stackoverflow.com/questions/34389...
Http://socketo.me/
Http://forum.codeigniter.com/thread-6340...
Reply: Recently, the project needs to synchronize messages from the server to the mobile end. What is the best solution? I first came up with two solutions:
First: ajax round-robin (obviously not a good method, because the server message is unknown. If the round-robin is maintained, even if the interval is several seconds, the mobile end does not end the round-robin operation, just like an infinite loop without terminating the operation)
Type 2: Use websocket to establish a persistent connection where the business needs to be updated in real time. google has a lot of information and many people on the internet suggest using Ratchet. The problem is, has anyone used this tool library? What are their similarities and differences with domestic workman ?? How to select these two tools...
By the way, the important thing is that the project is developed based on CI3, so the compatibility with ci3.
The following are some of my key information:
Http://stackoverflow.com/questions/34389...
Http://socketo.me/
Http://forum.codeigniter.com/thread-6340...
Real-time two-way communication must use Websocket, but I do not recommend using PHP as the websocket server. We recommend using nodejs
In addition, if it is only for server push, the browser can use EventSource, which is also an HTML5 standard.
Server MessageSynchronizationTo Mobile End
Two-way synchronization is required, which is not shown in your description.
Try third-party push, such as push and JPush.
For bidirectional access, you can use websocket.
Why not consider asynchronous push? The server pushes new messages to the mobile device, and the mobile device receives the message interface.