drmy1050 2013-10-08 20:23
浏览 65
已采纳

在同一台服务器上的HTTP用户会话之间进行通信 - php等待mysql字段更新?

I have a collaborative website where I need different sessions from different users to talk to each other (all sessions run php scripts on the same server). I was thinking of updating a "status" field in the mysql database and having other sessions from other users probing this field every second (using php).

Is there any potential issue with using such an approach (database caching etc...). Is there a better solution? thank you

  • 写回答

1条回答 默认 最新

  • dsunj08246 2013-10-08 20:47
    关注

    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.

    • A user leaves a message with the server,
    • The server stores the message
    • transmits it the next time a the recipient's ajax call checks in.
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥23 (标签-bug|关键词-密码错误加密)
  • ¥66 比特币地址如何生成taproot地址
  • ¥20 数学建模数学建模需要
  • ¥15 关于#lua#的问题,请各位专家解答!
  • ¥15 什么设备可以研究OFDM的60GHz毫米波信道模型
  • ¥15 不知道是该怎么引用多个函数片段
  • ¥30 关于用python写支付宝扫码付异步通知收不到的问题
  • ¥15 隐藏系统界面pdf的打印、下载按钮
  • ¥15 基于pso参数优化的LightGBM分类模型
  • ¥15 安装Paddleocr时报错无法解决