duanduanxi9441 2014-01-08 00:02
浏览 83

需要初学者Web开发人员的建议。 构建用户通知系统

web guru and all who interested,

I've built simple web application where users can post, comment, favourite articles and right know I've the idea to create a users notification system. At the beginning really simple: notify if user's post was favourited or commented. And I wonder what are the best practices and strategies for making it and of course the easiest way? I've read about web sockets technology, but not sure is this that I need for such simple functionality. Another idea is to make AJAX call let's say every 60s, taking user's ID and search if there's any new records in DB containing that ID. But I'm quite doubtful about efficiency of frequent calls to my server.

I believe you've got the idea and will advise me. Thanks in advance!

  • 写回答

1条回答 默认 最新

  • dounieqi6959 2014-01-08 00:50
    关注

    Unless I'm reading it wrong, it sounds like what you're after is way to do a real time server event push to the browser.

    In the past this was accomplished by either long polling or some other type of hack to do with keeping connections open or periodically opening connections (say every 10 seconds).

    Now with HTML5 websockets and SSE (Server Side events) such hacks aren't necessary.

    If all you want is one way (ie server to client) communication then you want to use SSE. http://www.html5rocks.com/en/tutorials/eventsource/basics/

    Browser support is good and non-adherence can be polyfilled. Here is a list: https://github.com/Modernizr/Modernizr/wiki/HTML5-Cross-browser-Polyfills#eventsource

    Hope this helps as a concept to get you started...

    评论

报告相同问题?

悬赏问题

  • ¥15 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?
  • ¥20 怎么用dlib库的算法识别小麦病虫害
  • ¥15 华为ensp模拟器中S5700交换机在配置过程中老是反复重启
  • ¥15 java写代码遇到问题,求帮助
  • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?