By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,730 Members | 1,540 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,730 IT Pros & Developers. It's quick & easy.

How to display poll for all logged users after the creation of the vote?

P: 1
I'm working on the project 'vote/poll' on android device's. I want it to work like this: - Users can login(I got REST API php for login/register and its okay for me and working), - Admin can create new voting(available options: yes, no) - i can do it with rest api and its easy for me(I'm beginner). My problem is how to display question and answers(yes/no) for all logged users? I think that I can make async method in client side like timer(send request to api per 1 sec and check new question in database, if it's new return response json) but i think that it's not professional(?) and very expensive(for server). Second solution is websocket but I have never used it and I'm afraid of it that I can't handle it. What do you think? Is there any other way?

BTW: 40 employees will use my system(Every Saturday for 3-5h only).
2 Weeks Ago #1
Share this Question
Share on Google+
1 Reply


gits
Expert Mod 5K+
P: 5,369
well 1 sec polling is really a bad idea - if it has to be that 'realtime' better use websockets (WS) or server side events (SSE). If it would be enough to poll each minute - then you probably can poll if thats easier for you to implement and you are under time pressure - but WS or SSE are to prefer. at least if it is a webapplication - what i assume from your post. If you have a native app - then the proper method would be push notifications i think since they would drain less battery.

PS: if you still decide to make 1sec XMLHttpRequest then its not simple as well - since they are async you cannot ensure when they return if you simply send them out and dont implement a serialization method so the returns are displayed in the correct timely order. So dont just fire them off with setInterval and think its done then :)
2 Weeks Ago #2

Post your reply

Sign in to post your reply or Sign up for a free account.