Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
+6 votes
1.6k views
in Plugins by
retagged by
Hi,

is it possible to make "On Site Notification" plugin realtime? Something like: on every 5 sec. check for notifications: if there is any - show, if not - ignore. All that without reloading page!

I am beginner in PHP but I know a lot about ajax, parsing data, front-end, and I am quick learner :)
Q2A version: 1.8.2
by
Are you aware that if you hit your server every 5 seconds for each user (using this polling technique you suggest) the server load will considerably increase?
by
That's why I asked here how to make that.
by
@Pupi Can it be an option at least? Not 5 seconds- may be about 20s and this is only for logged in users.
by
It can definitely be an option. There could even be a configurable interval in the settings
by
Thank you Pupi. Being open source I'll try if it works.
by
It *will* work! Feel free to ask any question if you get stuck :)
by
Thanks :) This is afterall the most useful plugin for Q2A I feel. Will be great if I can make it work.
by
Thank you pupi. It did work for me. But strangely adding the admin option is not working -- site is getting hanged when clicked on "Options" of most plugins. But works fine on 1.8.0. As someone elese reported seems a commong problem with Q2Apro-plugins with 1.8.3 -- when clicked on the plugin options.
by
Unless @q2apro is doings something weird in those admin forms (which I don't think so) the delay is just a browser-based perception. I bet that:

1. If you actually check the server performance it will be exactly the same, which would immediately confirm you're wrong (not necessarily that I'm right :P)
2. Clicking on admin options of any @q2apro plugins, or any plugin, or even a simple page refresh will result in that perception
3. If you open the plugin page, then you wait for 2 minutes, then you go to the plugin options there is no delay

Did I win the bet? :)
by
Not exactly Pupi. Actually when I click the plugin options, I can see a lot of MySQL processes getting spawned -- nearly 50 and all of them are in sleep. On second attempt I'm able to see the admin options. I'll make a localhost copy and test this carefully.

Meanwhile the real-time notice is working fine with 20s interval but hardly any user noticed that it is working :)
by
"I can see a lot of MySQL processes getting spawned -- nearly 50 and all of them are in sleep" => how many of them are spawned when you access the /activity section?
by
Almost nothing - at least nothing which goes to sleep. I just clicked the options of
http://www.q2apro.com/plugins/usersearch
plugin and it again hanged my site.
by
+2
by
Thank you Pupi. When you posted that then I didn't get what exactly you meant but now I do :)

Please log in or register to answer this question.

...