+ /**
+ * Runnable that continously long polls the server for commands
+ *
+ * @author Marius Gavrilescu <marius@ieval.ro>
+ */
+ private final class LongPollRunnable implements Runnable{
+ public void run(){
+ final ConnectivityManager man=(ConnectivityManager) getSystemService(CONNECTIVITY_SERVICE);
+ final HttpCallExecutableRunnable runnable=new HttpCallExecutableRunnable("/get", null, FonBotMainService.this, new PollResultCallback(FonBotMainService.this), false);
+
+ Log.d("LongPollRunnable", "Long polling started");
+ while(man.getActiveNetworkInfo() != null && man.getActiveNetworkInfo().isConnected())
+ try {
+ runnable.run();
+ } catch (final Exception ex){
+ ex.printStackTrace();
+ }
+ Log.d("LongPollRunnable", "Long polling stopped");
+ }
+ }
+