Like some user x updates some info on website and some other user z should receive a notification about x's update without he refreshing the page.
3条回答 默认 最新
- dongliyun3301 2016-10-19 15:28关注
This is a very large question that implies a lot of different notions. You should work at different levels (server, client and database) with multiple possibilities each time.
1) client pull
In the client page (user Z), you should send AJAX requests every once in a while (every 1 sec?) and the script on the server side should detect what values have been changed since the last request. This heavily relies on the existence of a timestamp field that is updated using triggers on every SQL insert or update (or delete?).
2) server push
Using websockets, the client (user Z) keeps an open connection to the server. On the server, a process is running constantly in the background and periodically checks the database (every 1 sec?) for updates (again based on timestamps) and sends the difference to the client on the websocket.
Detect changes
If your database does not fix some identifiable timestamp or id or else, you may try to execute an external program using triggers which will probably add another level of complexity.
本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 无用评论 打赏 举报
悬赏问题
- ¥15 加热介质是液体,换热器壳侧导热系数和总的导热系数怎么算
- ¥15 想问一下树莓派接上显示屏后出现如图所示画面,是什么问题导致的
- ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
- ¥15 cmd cl 0x000007b
- ¥20 BAPI_PR_CHANGE how to add account assignment information for service line
- ¥500 火焰左右视图、视差(基于双目相机)
- ¥100 set_link_state
- ¥15 虚幻5 UE美术毛发渲染
- ¥15 CVRP 图论 物流运输优化
- ¥15 Tableau online 嵌入ppt失败