我有一个协作网站,我需要来自不同用户的不同会话来相互交谈(所有会话在同一台服务器上运行 php 脚本)。我正在考虑更新 mysql 数据库中的“状态”字段,并让其他用户的其他会话每秒探测该字段(使用 php)。
使用这种方法(数据库缓存等)是否有任何潜在问题。有更好的解决方案吗?谢谢你
Unless you want to have your users' browsers reload the entire page each second, you should use something like ajax to poll the server.
For the states, you could have your server update a json file that your clients can download periodically.
For inter-session communication, you could have a system with a message queue whereby messages are either transmitted specifically to a particular user or broadcast to all.