Currently, I am working on a social networking website (Thinkphp and mysql). I want to notify other online users when some users trigger some conditions, such as sending a personal letter and a small gift to the other party.
At present, I think the only way is:
Put the message to be sent into redis, and then make a Redis query in the base class Action, so that the user will check whether the Redis has any content for each operation. However, this is not very scientific and belongs to passive query.
Please ask everyone what good methods they have, thank you very much!
This is definitely what you want, implemented by websocket plus workerman.
Principle: after the user opens the page, the browser will automatically send a websocket connection to the back-end server (the browser supports HTML5 or Flash). the back-end hold these connections. when it wants to push messages to the browser, it can write data to these websocket connections.
- Non-polling, high performance, ordinary servers can maintain tens of thousands of connections
- Good real-time performance
- Compatible with various browsers including ie6 (client supports either flash or html5)