0

I am using the Parse.com database service for a PhoneGap app we are creating. We have users that can mark themselves (First User) "Available" for their friends (Second User), and I need a way to listen for that toggle in availability on the second user's side, so their friends list can update without having the refresh the page.

With Parse, your interaction with the database is monitored by # API calls and Burst Limit (Number of API calls per second) so I need to only call the database for the change in status when it is actually changed, I can't keep a setInterval on otherwise it will make the burst limit too small for other user, or it will cause to many API calls for no reason if the status isn't changing.

How can I got about this?

1 Answer 1

1

You should try socket.io with intercom.js. The first one does the pushing to the client, the second one ensures that only a single socket is open by multiple tabs. Socket.io has multiple fallbacks on client side, it can use websockets, flash, maybe even long-polling I guess...

The server side should support sockets. By nodejs it is very easy. By classical http languages, for example php+apache just the long-polling will work I think.

Be aware that your data pushing application will be socket based and not request-response based, so it won't be part of you webservice. Probably you should only push, that the user list must be refreshed. So there won't be any duplicated code...

Sign up to request clarification or add additional context in comments.

12 Comments

I'll take a look at this, I'll accept your answer in a bit if nothing else comes in. I appreciate it.
Looks like we are going to have to change to a service like Pubnub with real time capabilities... thanks!
Not necessarily. You can run 2 services, one for socket connection and one with a REST or webservice interface. So you don't have to drop your existing code, just write a simple socket api based on database triggers for example...
Are you sure that this small feature does worth the effort?
inf3rno, for the small feature I wanted to implement right now, no. But for our big feature, yes. GPS has to update constantly, and this will help.
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.