admin管理员组文章数量:1353252
I am trying to understand how push services work. I believe push notifications are where the server 'pushes' a new item to the client, but I don't know how that works in practice.
For example, how does a phone "know" that it has a new email to pick up if it doesn't manually check the server for a new message?
Also, how can this be implemented for a chat program or notification system for a small website? Are there php classes out there, etc..?
I am trying to understand how push services work. I believe push notifications are where the server 'pushes' a new item to the client, but I don't know how that works in practice.
For example, how does a phone "know" that it has a new email to pick up if it doesn't manually check the server for a new message?
Also, how can this be implemented for a chat program or notification system for a small website? Are there php classes out there, etc..?
Share Improve this question asked Oct 3, 2009 at 8:21 chrischris 21.3k29 gold badges78 silver badges90 bronze badges2 Answers
Reset to default 8For example, how does a phone "know" that it has a new email to pick up if it doesn't manually check the server for a new message?
PUSH implementations vary, depending on the protocol, but the principles remain the same. A connection is kept open between the client and server and the client is notified by the server of new events. This utilises less bandwidth and typically leads to faster interaction than the client periodically asking the server whether there are any new events waiting.
As a demonstration, this is how PUSH IMAP (known as IDLE) mail works:
- The client logs into the email server as normal.
- During the login process the server advertises that it is capable of
IDLE
. - The client performs a check and download of new messages as normal.
- Instead of periodically polling for new messages the client issues an
IDLE
mand. - The session between the server and client remains quiet.
- When new mail arrives and the server notifies that the messages
EXISTS
. - The client can then exit
IDLE
mode withDONE
and download those messages. - Repeat from step 4.
I'm assuming you are talking about an HTTP client? It is generally done with Server push or Comet technology. Instead of simply closing the HTTP connection after a page loaded clients keep the connection open to receive server push messages.
Have a look at this SO entry for some details on how to do it with JQuery.
There are some examples for PHP on the web although you might want to look at a etd server if you expect more than just a handful of connections otherwise you might run out of Apache server connections.
本文标签: phpHow does push emailchat work Can it be implemented easily for small websitesStack Overflow
版权声明:本文标题:php - How does push emailchat work? Can it be implemented easily for small websites? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1743882595a2555472.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论