I am writing an implementation of APE protocol for chat in Android. In one case I need to send a request, which is kept on server until I send another request (and then the server returns response to the first request).
How can I properly do this operation using Robospice? I set up the library to use 2 threads, but it does not work properly - a few first request work well, but after some time it Robospice says - request added to queue
but the request is not send.
I attach my log:
04-25 16:39:46.094 /com.xx.xx D/CHAT﹕ CHECK
04-25 16:39:46.184 /com.xx.xx D/CHAT﹕ SENDING: [{"sessid":"18c61b18e5a8ce1513e80b8b50c3d865","cmd":"CHECK","chl":3}]
04-25 16:39:56.094 /com.xx.xx D/CHAT﹕ CHECK
04-25 16:39:56.214 /com.xx.xx D/CHAT﹕ SENDING: [{"sessid":"18c61b18e5a8ce1513e80b8b50c3d865","cmd":"CHECK","chl":4}]
04-25 16:39:57.004 /com.xx.xx D/CHAT﹕ RECIVED: [{"data":{"code":null,"from":null,"msg":null,"pipe":null,"sessid":null,"user":null,"users":null,"value":"null"},"raw":"CLOSE","time":"1398436529"}]
// For now it works ok - I send first request, then after 10 secs I send another and get response to first
04-25 16:40:06.095 /com.xx.xx D/CHAT﹕ CHECK
04-25 16:40:06.305 /com.xx.xx D/CHAT﹕ SENDING: [{"sessid":"18c61b18e5a8ce1513e80b8b50c3d865","cmd":"CHECK","chl":5}]
04-25 16:40:07.036 /com.xx.xx D/CHAT﹕ RECIVED: [{"data":{"code":null,"from":null,"msg":null,"pipe":null,"sessid":null,"user":null,"users":null,"value":"null"},"raw":"CLOSE","time":"1398436539"}]
// Up I get response for second request
//From now I see that functions for starting request is launched, but no request is made
04-25 16:40:16.105 /com.xx.xx D/CHAT﹕ CHECK
04-25 16:40:26.124 /com.xx.xx D/CHAT﹕ CHECK
04-25 16:40:36.134 /com.xx.xx D/CHAT﹕ CHECK
I use this code to do first request and than start a loop to do next request every 10 seconds:
check(); //does request
periodicCheck.postDelayed(periodicCheckRequest, 10000); //starts a loop
private Handler periodicCheck;
private Runnable periodicCheckRequest = new Runnable() {
@Override
public void run() {
check(); //does request
periodicCheck.postDelayed(this, 10000);
}
};
Any ideas why it does not work as expected?