+ // Notify connection status
+ if (this.client.ready) {
+ this.command(CONNECT, null);
+ this.notify("Connected", android.R.drawable.presence_online);
+ } else {
+ this.command(DISCONNECT, null);
+ this.notify("Connetion aborted", android.R.drawable.presence_offline);
+ }
+
+ // Process messages
+ while (this.client.ready) {
+ Message msg = this.client.recv();
+ if (msg == null)
+ break;
+ this.command(MESSAGE, msg);
+ }
+
+ // Notify disconnect disconnected
+ this.notify("Disconnected", android.R.drawable.presence_offline);
+ this.command(DISCONNECT, null);
+
+ // Shutdown the client
+ this.client.abort();
+ this.thread = null;