Event Driven Front End On Yii
Posted 16 November 2012 - 08:16 AM
I'm wondering what would be the best way to do user event driven front ends in Yii
what I mean is : let's say many people are on one same page (=url)
if a status of something is changed by a user
how to make it refresh to everyone
I know the ajax pinging technique but it's so slow, and generates constent pinging requests
I also looked into websockets which is far from being a standard and unavailable on all browsers for the moment
which brings me to the Forum
can it be done smoothly using Yii ?
or should I look into other frameworks like nodeJS
I'd prefer to stick with Yii since my whole application is on Yii
Thanks for the insight
Posted 16 November 2012 - 09:01 AM
You could create a function called onBeginRequest and set a variable according to sql data
this sql data will be set when user status changed
find our demo Yii extension on www.webkit.gr
Is it post useful? please v++ ;)
Posted 16 November 2012 - 09:30 AM
Every connected client might implement a similar pattern to re-distribute incomming messages to interested components of client side logic, but this has no longer to do with passing messages from server to client...
My point is: as soon as you have established the concept of passing messages from server to client, and you have a defined interface, everything else becomes an implementation detail.
If you have clients that know how to work with websockets, you can provide a second implementation of your subject, that doesn't need to store messages for later retrieval, but simply pushes them to the bleeding edge client.
The benefit is, that the matter of how the message finds its way to the client is transparent to your yii application. It only works with the subject interface you defined in the first step.
So in a nutshell: Yii probably won't do much to help you accomplish the message passing piece of work. But it can be implemented and if done right, it can be re-used as an extension.
Oh, and I'd love to hear some more opinions on that topic.