Hi,
Can we suspend the activity till we get a response from server?
I have posted data to the php server through HTTPClient. The php server searches the database for the response. But if there is no response in the database, a person from the server side need to reply to it, like a chat. My requirement is to wait for reply and to get the reply from the server with no triggering from the user side.
I have a php page that selects new entries from the database. Now I need to call this file from the activity. Please help me in implementing this...
Thanks for the reply.
I started a new thread, call the data to the activity and was successful in it. A user at the server side sends reply to the message, there may be delay for response. I want to get that reply message into my application when the user provides one. The application is miniature form of a chat system, When the client side user sends a message, a user at the server side sees it and replies to it. There will be no event from the client side.
I want to periodically check the server for reply from the application. Please suggest me how to do it?
Should I implement it from the server side itself?
Ah ha. Now I understand - you're wondering how to deal with 2-way events in a request-response model. There are several approaches you can take:
1) Keepalive connection where the server responds when appropriate and the client just stays connected, listening
2) Polling - the client requests an update every n seconds
I believe the most common way to do real-time systems using HTTP these days is option #1, but this is not my area of expertise so you may want to look into it more.
Hi,
Thanks for the reply.
I couldn't find any hint searching google. Can u please suggest me some stuffs to refer to....
thanks in advance.
Search for "http persistent connections" and start reading through everything. I don't personally know how to do it - I just know that it's probably what you want.
You'll want to start a thread to retrieve the data and have it call back to your activity or to a handler of some type so that the UI can respond when data is available.