How does incoming mail notification on Gmail works?

前端 未结 4 601
无人共我
无人共我 2021-01-04 05:50

I\'m wondering how it\'s implemented in Gmail, that every time you receive e-mail, the list of mails is automatically refreshed. It looks like the server is sending some kin

4条回答
  •  情话喂你
    2021-01-04 06:25

    It must be some kind of ajax listener that get informations every X seconds.

    I already set something like that for one of my projects. What I was doing is calling a function that was returning true or false. True if the page needed to be refreshed, false otherwise. Then if you have an update, you do another call to get the actual update. This way you don't have to refresh everything every time... but it's still intense on the server if you have a lot of users.

    In other words and like chaos said, it's polling the server.

提交回复
热议问题