how to implement facebook like notification?

前端 未结 5 1097
面向向阳花
面向向阳花 2020-12-22 22:32

I am trying to implement a Facebook-like live notifications system to notify users whenever someone adds them as friend, like their post or posts replies to their comments.

相关标签:
5条回答
  • 2020-12-22 22:57

    You should look into COMET techniques, such as forever frame (tutorial) and long polling. That allows you to have a form of a server->client push communication.

    0 讨论(0)
  • 2020-12-22 22:58

    You basically set a request up, like callng the service that asks your server/db for the notifications of that user. You may do a while loop that retries if theres no notification (maybe Thread.Sleep in between searches). Your js request will timeout, then you can call the function again in timeout. This means long polling afaik

    0 讨论(0)
  • 2020-12-22 23:11

    I am really surprised nobody has mentioned PubNub and Pusher

    These two (competitors) are building infrastructure which allows for realtime notifications, just like Facebook.

    0 讨论(0)
  • 2020-12-22 23:15

    The only way to do it is to have some sort of mechanism (e.g. Javascript) to repeatedly poll the server for updates. Doing server pushes to web browsers isn't possible.

    0 讨论(0)
  • 2020-12-22 23:20

    Facebook notification

    0 讨论(0)
提交回复
热议问题