I'm currently developing a website that requires a push notification style system like Facebook notifications. I would like the user to be notified when an event occurs such as "X added you as a friend"...
I've been looking into my options however they seem to be extremely limited as the website will be hosted on a shared hosting platform therefore I have limited access etc.
1) Looking at long polling comet style - as I can't run Python on the server, my only option here is PHP for the server script however due to thread consumption this probably isn't a very scalable option.
2) WebSockets - these look great but with browser support limited it doesn't seem plausible just yet..
So - has anyone accomplished this on a shared hosting platform? I'd rather not have to use a service like Pusher.
Many thanks!! :)
PS - I'm using Yii framework - any solutions with that in mind would be even better
use Ratchet , it is a WebSocket for PHP.
Ratchet is a loosely coupled PHP library providing developers with tools to create real time, bi-directional applications between clients and servers over WebSockets. This is not your Grandfather's Internet.
here is a helloworld example.
Use html5 SSE (Server sent dom events) for chrome, firefox, opera and ie10
for older versions of IE use iframe loading as a fallback.
all those techniques should work well with any kind of shared hosting since they do not require any kind of server side setup.
https://stackoverflow.com/a/1086448/1063333 :
A common method of doing such notifications is to poll a script on the server (using ajax) on a given interval (perhaps every few seconds), to check if something has happened
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.