ping stuff

This commit is contained in:
Daniel Gultsch 2014-03-11 15:44:22 +01:00
parent 08023210ba
commit 0d516b0603
5 changed files with 240 additions and 188 deletions

View file

@ -144,7 +144,11 @@ public class MucOptions {
if (split.length == 2) { if (split.length == 2) {
return split[1]; return split[1];
} else { } else {
if (conversation.getAccount()!=null) {
return conversation.getAccount().getUsername(); return conversation.getAccount().getUsername();
} else {
return null;
}
} }
} }

View file

@ -8,11 +8,10 @@ public class EventReceiver extends BroadcastReceiver {
public void onReceive(Context context, Intent intent) { public void onReceive(Context context, Intent intent) {
Intent mIntentForService = new Intent(context, Intent mIntentForService = new Intent(context,
XmppConnectionService.class); XmppConnectionService.class);
mIntentForService.putExtra("ping", intent.getBooleanExtra("ping",false)); if (intent.getAction() != null) {
if ((intent.getAction() != null) mIntentForService.setAction(intent.getAction());
&& (intent.getAction() } else {
.equals("android.intent.action.BOOT_COMPLETED"))) { mIntentForService.setAction("other");
} }
context.startService(mIntentForService); context.startService(mIntentForService);
} }

View file

@ -7,7 +7,6 @@ import java.util.Hashtable;
import java.util.List; import java.util.List;
import java.util.Random; import java.util.Random;
import org.json.JSONException;
import org.openintents.openpgp.util.OpenPgpApi; import org.openintents.openpgp.util.OpenPgpApi;
import org.openintents.openpgp.util.OpenPgpServiceConnection; import org.openintents.openpgp.util.OpenPgpServiceConnection;
@ -70,7 +69,8 @@ public class XmppConnectionService extends Service {
public long startDate; public long startDate;
private static final int PING_INTERVAL = 300; private static final int PING_MAX_INTERVAL = 30;
private static final int PING_MIN_INTERVAL = 10;
private static final int PING_TIMEOUT = 2; private static final int PING_TIMEOUT = 2;
private List<Account> accounts; private List<Account> accounts;
@ -80,7 +80,8 @@ public class XmppConnectionService extends Service {
private OnAccountListChangedListener accountChangedListener = null; private OnAccountListChangedListener accountChangedListener = null;
private OnTLSExceptionReceived tlsException = null; private OnTLSExceptionReceived tlsException = null;
public void setOnTLSExceptionReceivedListener(OnTLSExceptionReceived listener) { public void setOnTLSExceptionReceivedListener(
OnTLSExceptionReceived listener) {
tlsException = listener; tlsException = listener;
} }
@ -171,7 +172,8 @@ public class XmppConnectionService extends Service {
if (convChangedListener != null) { if (convChangedListener != null) {
convChangedListener.onConversationListChanged(); convChangedListener.onConversationListChanged();
} else { } else {
UIHelper.updateNotification(getApplicationContext(), getConversations(), notify); UIHelper.updateNotification(getApplicationContext(),
getConversations(), notify);
} }
} }
}; };
@ -197,7 +199,7 @@ public class XmppConnectionService extends Service {
if (convChangedListener != null) { if (convChangedListener != null) {
convChangedListener.onConversationListChanged(); convChangedListener.onConversationListChanged();
} }
scheduleWakeupCall(PING_INTERVAL, true); scheduleWakeupCall(PING_MAX_INTERVAL, true);
} else if (account.getStatus() == Account.STATUS_OFFLINE) { } else if (account.getStatus() == Account.STATUS_OFFLINE) {
Log.d(LOGTAG, "onStatusChanged offline"); Log.d(LOGTAG, "onStatusChanged offline");
databaseBackend.clearPresences(account); databaseBackend.clearPresences(account);
@ -215,12 +217,16 @@ public class XmppConnectionService extends Service {
@Override @Override
public void onPresencePacketReceived(Account account, public void onPresencePacketReceived(Account account,
PresencePacket packet) { PresencePacket packet) {
if (packet.hasChild("x")&&(packet.findChild("x").getAttribute("xmlns").startsWith("http://jabber.org/protocol/muc"))) { if (packet.hasChild("x")
Conversation muc = findMuc(packet.getAttribute("from").split("/")[0]); && (packet.findChild("x").getAttribute("xmlns")
.startsWith("http://jabber.org/protocol/muc"))) {
Conversation muc = findMuc(packet.getAttribute("from").split(
"/")[0]);
if (muc != null) { if (muc != null) {
int error = muc.getMucOptions().getError(); int error = muc.getMucOptions().getError();
muc.getMucOptions().processPacket(packet); muc.getMucOptions().processPacket(packet);
if ((muc.getMucOptions().getError()!=error)&&(convChangedListener!=null)) { if ((muc.getMucOptions().getError() != error)
&& (convChangedListener != null)) {
Log.d(LOGTAG, "muc error status changed"); Log.d(LOGTAG, "muc error status changed");
convChangedListener.onConversationListChanged(); convChangedListener.onConversationListChanged();
} }
@ -250,10 +256,12 @@ public class XmppConnectionService extends Service {
if (pgp != null) { if (pgp != null) {
Element x = packet.findChild("x"); Element x = packet.findChild("x");
if ((x != null) if ((x != null)
&& (x.getAttribute("xmlns").equals("jabber:x:signed"))) { && (x.getAttribute("xmlns")
.equals("jabber:x:signed"))) {
try { try {
contact.setPgpKeyId(pgp.fetchKeyId(packet.findChild("status") contact.setPgpKeyId(pgp.fetchKeyId(packet
.getContent(), x.getContent())); .findChild("status").getContent(), x
.getContent()));
} catch (OpenPgpException e) { } catch (OpenPgpException e) {
Log.d(LOGTAG, "faulty pgp. just ignore"); Log.d(LOGTAG, "faulty pgp. just ignore");
} }
@ -309,6 +317,8 @@ public class XmppConnectionService extends Service {
private OpenPgpServiceConnection pgpServiceConnection; private OpenPgpServiceConnection pgpServiceConnection;
private PgpEngine mPgpEngine = null; private PgpEngine mPgpEngine = null;
private Intent pingIntent;
private PendingIntent pendingPingIntent = null;
public PgpEngine getPgpEngine() { public PgpEngine getPgpEngine() {
if (pgpServiceConnection.isBound()) { if (pgpServiceConnection.isBound()) {
@ -386,35 +396,58 @@ public class XmppConnectionService extends Service {
@Override @Override
public int onStartCommand(Intent intent, int flags, int startId) { public int onStartCommand(Intent intent, int flags, int startId) {
ConnectivityManager cm = (ConnectivityManager) getApplicationContext().getSystemService(Context.CONNECTIVITY_SERVICE); Log.d(LOGTAG,"calling start service. caller was:"+intent.getAction());
// internet and online last_received - list_ping >= max_ping : ping
// internet and online last_ping - last_received >= ping_timeout :
// reconnect
// internet and offline and enabled : connect (Threat start)
// no internet - set no internet
ConnectivityManager cm = (ConnectivityManager) getApplicationContext()
.getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo activeNetwork = cm.getActiveNetworkInfo(); NetworkInfo activeNetwork = cm.getActiveNetworkInfo();
boolean isConnected = activeNetwork != null boolean isConnected = activeNetwork != null
&& activeNetwork.isConnected(); && activeNetwork.isConnected();
for (Account account : accounts) { for (Account account : accounts) {
if (!account.isOptionSet(Account.OPTION_DISABLED)) {
if (!isConnected) { if (!isConnected) {
account.setStatus(Account.STATUS_NO_INTERNET); account.setStatus(Account.STATUS_NO_INTERNET);
} else { } else {
if (account.getStatus() == Account.STATUS_NO_INTERNET) { if (account.getStatus() == Account.STATUS_NO_INTERNET) {
account.setStatus(Account.STATUS_OFFLINE); account.setStatus(Account.STATUS_OFFLINE);
} }
// TODO 3 remaining cases
if (account.getStatus() == Account.STATUS_ONLINE) {
long lastReceived = account.getXmppConnection().lastPaketReceived;
long lastSent = account.getXmppConnection().lastPingSent;
if (lastSent - lastReceived >= PING_TIMEOUT * 1000) {
Log.d(LOGTAG, account.getJid() + ": ping timeout");
this.reconnectAccount(account);
} else if (SystemClock.elapsedRealtime() - lastReceived >= PING_MIN_INTERVAL * 1000) {
account.getXmppConnection().sendPing();
account.getXmppConnection().lastPingSent = SystemClock.elapsedRealtime();
this.scheduleWakeupCall(2, false);
}
} else if (account.getStatus() == Account.STATUS_OFFLINE) {
if (account.getXmppConnection() == null) {
account.setXmppConnection(this
.createConnection(account));
}
account.getXmppConnection().lastPingSent = SystemClock.elapsedRealtime();
new Thread(account.getXmppConnection()).start();
} else {
Log.d(LOGTAG,account.getJid()+": status="+account.getStatus());
}
//in any case. reschedule wakup call
this.scheduleWakeupCall(PING_MAX_INTERVAL, true);
} }
if (accountChangedListener != null) { if (accountChangedListener != null) {
accountChangedListener.onAccountListChangedListener(); accountChangedListener.onAccountListChangedListener();
} }
if ((!account.isOptionSet(Account.OPTION_DISABLED))&&(isConnected)) {
if (account.getXmppConnection() == null) {
account.setXmppConnection(this.createConnection(account));
}
if (account.getStatus()==Account.STATUS_OFFLINE) {
Thread thread = new Thread(account.getXmppConnection());
thread.start();
} else {
if (intent.getBooleanExtra("ping", false)) {
Log.d(LOGTAG,"start service ping");
ping(account,PING_TIMEOUT);
}
}
} }
} }
return START_STICKY; return START_STICKY;
@ -432,7 +465,6 @@ public class XmppConnectionService extends Service {
getApplicationContext(), "org.sufficientlysecure.keychain"); getApplicationContext(), "org.sufficientlysecure.keychain");
this.pgpServiceConnection.bindToService(); this.pgpServiceConnection.bindToService();
} }
@Override @Override
@ -446,18 +478,39 @@ public class XmppConnectionService extends Service {
} }
protected void scheduleWakeupCall(int seconds, boolean ping) { protected void scheduleWakeupCall(int seconds, boolean ping) {
long timeToWake = SystemClock.elapsedRealtime() + seconds * 1000;
Context context = getApplicationContext(); Context context = getApplicationContext();
AlarmManager alarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE); AlarmManager alarmManager = (AlarmManager) context
Intent intent = new Intent(context, EventReceiver.class); .getSystemService(Context.ALARM_SERVICE);
intent.putExtra("ping", ping);
PendingIntent alarmIntent = PendingIntent.getBroadcast(context, 0, intent, 0);
alarmManager.set(AlarmManager.ELAPSED_REALTIME_WAKEUP,
SystemClock.elapsedRealtime() +
seconds * 1000, alarmIntent);
if (ping) { if (ping) {
if (this.pingIntent==null) {
this.pingIntent = new Intent(context, EventReceiver.class);
this.pingIntent.setAction("ping");
this.pingIntent.putExtra("time", timeToWake);
this.pendingPingIntent = PendingIntent.getBroadcast(context, 0,
this.pingIntent, 0);
alarmManager.set(AlarmManager.ELAPSED_REALTIME_WAKEUP,timeToWake, pendingPingIntent);
Log.d(LOGTAG,"schedule ping in "+seconds+" seconds"); Log.d(LOGTAG,"schedule ping in "+seconds+" seconds");
} else { } else {
Log.d(LOGTAG,"schedule reconnect in "+seconds+" seconds"); long scheduledTime = this.pingIntent.getLongExtra("time", 0);
if (scheduledTime<SystemClock.elapsedRealtime() || (scheduledTime > timeToWake)) {
this.pingIntent.putExtra("time", timeToWake);
alarmManager.cancel(this.pendingPingIntent);
this.pendingPingIntent = PendingIntent.getBroadcast(context, 0,
this.pingIntent, 0);
alarmManager.set(AlarmManager.ELAPSED_REALTIME_WAKEUP,timeToWake, pendingPingIntent);
Log.d(LOGTAG,"reschedule old ping to ping in "+seconds+" seconds");
}
}
} else {
Intent intent = new Intent(context, EventReceiver.class);
intent.setAction("ping_check");
PendingIntent alarmIntent = PendingIntent.getBroadcast(context, 0,
intent, 0);
alarmManager.set(AlarmManager.ELAPSED_REALTIME_WAKEUP,timeToWake, alarmIntent);
} }
} }
@ -470,13 +523,16 @@ public class XmppConnectionService extends Service {
connection.setOnPresencePacketReceivedListener(this.presenceListener); connection.setOnPresencePacketReceivedListener(this.presenceListener);
connection connection
.setOnUnregisteredIqPacketReceivedListener(this.unknownIqListener); .setOnUnregisteredIqPacketReceivedListener(this.unknownIqListener);
connection.setOnTLSExceptionReceivedListener(new OnTLSExceptionReceived() { connection
.setOnTLSExceptionReceivedListener(new OnTLSExceptionReceived() {
@Override @Override
public void onTLSExceptionReceived(String fingerprint, Account account) { public void onTLSExceptionReceived(String fingerprint,
Account account) {
Log.d(LOGTAG, "tls exception arrived in service"); Log.d(LOGTAG, "tls exception arrived in service");
if (tlsException != null) { if (tlsException != null) {
tlsException.onTLSExceptionReceived(fingerprint,account); tlsException.onTLSExceptionReceived(fingerprint,
account);
} }
} }
}); });
@ -624,7 +680,8 @@ public class XmppConnectionService extends Service {
Element query = new Element("query"); Element query = new Element("query");
query.setAttribute("xmlns", "jabber:iq:roster"); query.setAttribute("xmlns", "jabber:iq:roster");
if (!"".equals(account.getRosterVersion())) { if (!"".equals(account.getRosterVersion())) {
Log.d(LOGTAG,account.getJid()+ ": fetching roster version "+account.getRosterVersion()); Log.d(LOGTAG, account.getJid() + ": fetching roster version "
+ account.getRosterVersion());
} else { } else {
Log.d(LOGTAG, account.getJid() + ": fetching roster"); Log.d(LOGTAG, account.getJid() + ": fetching roster");
} }
@ -638,7 +695,8 @@ public class XmppConnectionService extends Service {
IqPacket packet) { IqPacket packet) {
Element roster = packet.findChild("query"); Element roster = packet.findChild("query");
if (roster != null) { if (roster != null) {
Log.d(LOGTAG,account.getJid()+": processing roster"); Log.d(LOGTAG, account.getJid()
+ ": processing roster");
processRosterItems(account, roster); processRosterItems(account, roster);
StringBuilder mWhere = new StringBuilder(); StringBuilder mWhere = new StringBuilder();
mWhere.append("jid NOT IN("); mWhere.append("jid NOT IN(");
@ -663,7 +721,8 @@ public class XmppConnectionService extends Service {
} }
} else { } else {
Log.d(LOGTAG,account.getJid()+": empty roster returend"); Log.d(LOGTAG, account.getJid()
+ ": empty roster returend");
} }
mergePhoneContactsWithRoster(new OnPhoneContactsMerged() { mergePhoneContactsWithRoster(new OnPhoneContactsMerged() {
@ -908,8 +967,7 @@ public class XmppConnectionService extends Service {
nick = conversation.getAccount().getUsername(); nick = conversation.getAccount().getUsername();
} }
PresencePacket packet = new PresencePacket(); PresencePacket packet = new PresencePacket();
packet.setAttribute("to", muc + "/" packet.setAttribute("to", muc + "/" + nick);
+ nick);
Element x = new Element("x"); Element x = new Element("x");
x.setAttribute("xmlns", "http://jabber.org/protocol/muc"); x.setAttribute("xmlns", "http://jabber.org/protocol/muc");
if (conversation.getMessages().size() != 0) { if (conversation.getMessages().size() != 0) {
@ -926,6 +984,7 @@ public class XmppConnectionService extends Service {
private OnRenameListener renameListener = null; private OnRenameListener renameListener = null;
private boolean pongReceived; private boolean pongReceived;
public void setOnRenameListener(OnRenameListener listener) { public void setOnRenameListener(OnRenameListener listener) {
this.renameListener = listener; this.renameListener = listener;
} }
@ -946,13 +1005,16 @@ public class XmppConnectionService extends Service {
} }
}); });
PresencePacket packet = new PresencePacket(); PresencePacket packet = new PresencePacket();
packet.setAttribute("to", conversation.getContactJid().split("/")[0]+"/"+nick); packet.setAttribute("to",
conversation.getContactJid().split("/")[0] + "/" + nick);
packet.setAttribute("from", conversation.getAccount().getFullJid()); packet.setAttribute("from", conversation.getAccount().getFullJid());
conversation.getAccount().getXmppConnection().sendPresencePacket(packet, new OnPresencePacketReceived() { conversation.getAccount().getXmppConnection()
.sendPresencePacket(packet, new OnPresencePacketReceived() {
@Override @Override
public void onPresencePacketReceived(Account account, PresencePacket packet) { public void onPresencePacketReceived(Account account,
PresencePacket packet) {
final boolean changed; final boolean changed;
String type = packet.getAttribute("type"); String type = packet.getAttribute("type");
changed = (!"error".equals(type)); changed = (!"error".equals(type));
@ -960,8 +1022,10 @@ public class XmppConnectionService extends Service {
options.getOnRenameListener().onRename(false); options.getOnRenameListener().onRename(false);
} else { } else {
if (type == null) { if (type == null) {
options.getOnRenameListener().onRename(true); options.getOnRenameListener()
options.setNick(packet.getAttribute("from").split("/")[1]); .onRename(true);
options.setNick(packet.getAttribute("from")
.split("/")[1]);
} else { } else {
options.processPacket(packet); options.processPacket(packet);
} }
@ -969,7 +1033,8 @@ public class XmppConnectionService extends Service {
} }
}); });
} else { } else {
String jid = conversation.getContactJid().split("/")[0]+"/"+nick; String jid = conversation.getContactJid().split("/")[0] + "/"
+ nick;
conversation.setContactJid(jid); conversation.setContactJid(jid);
databaseBackend.updateConversation(conversation); databaseBackend.updateConversation(conversation);
if (conversation.getAccount().getStatus() == Account.STATUS_ONLINE) { if (conversation.getAccount().getStatus() == Account.STATUS_ONLINE) {
@ -983,11 +1048,13 @@ public class XmppConnectionService extends Service {
packet.setAttribute("to", conversation.getContactJid()); packet.setAttribute("to", conversation.getContactJid());
packet.setAttribute("from", conversation.getAccount().getFullJid()); packet.setAttribute("from", conversation.getAccount().getFullJid());
packet.setAttribute("type", "unavailable"); packet.setAttribute("type", "unavailable");
conversation.getAccount().getXmppConnection().sendPresencePacket(packet); conversation.getAccount().getXmppConnection()
.sendPresencePacket(packet);
conversation.getMucOptions().setOffline(); conversation.getMucOptions().setOffline();
} }
public void disconnect(final Account account, boolean blocking) { public void disconnect(final Account account, boolean blocking) {
if (account.getStatus() == Account.STATUS_ONLINE) {
List<Conversation> conversations = getConversations(); List<Conversation> conversations = getConversations();
for (int i = 0; i < conversations.size(); i++) { for (int i = 0; i < conversations.size(); i++) {
Conversation conversation = conversations.get(i); Conversation conversation = conversations.get(i);
@ -1020,6 +1087,7 @@ public class XmppConnectionService extends Service {
account.setXmppConnection(null); account.setXmppConnection(null);
} }
} }
}
@Override @Override
public IBinder onBind(Intent intent) { public IBinder onBind(Intent intent) {
@ -1141,6 +1209,7 @@ public class XmppConnectionService extends Service {
this.tlsException = null; this.tlsException = null;
} }
//TODO dont let thread sleep but schedule wake up
public void reconnectAccount(final Account account) { public void reconnectAccount(final Account account) {
new Thread(new Runnable() { new Thread(new Runnable() {
@ -1159,46 +1228,4 @@ public class XmppConnectionService extends Service {
} }
}).start(); }).start();
} }
public void ping(final Account account,final int timeout) {
account.getXmppConnection().r();
Log.d(LOGTAG,account.getJid()+": sending ping");
IqPacket iq = new IqPacket(IqPacket.TYPE_GET);
Element ping = new Element("ping");
iq.setAttribute("from",account.getFullJid());
ping.setAttribute("xmlns", "urn:xmpp:ping");
iq.addChild(ping);
pongReceived = false;
account.getXmppConnection().sendIqPacket(iq, new OnIqPacketReceived() {
@Override
public void onIqPacketReceived(Account account, IqPacket packet) {
pongReceived = true;
}
});
new Thread(new Runnable() {
@Override
public void run() {
int i = 0;
while(i <= (5 * timeout)) {
if (pongReceived) {
scheduleWakeupCall(PING_INTERVAL,true);
break;
}
try {
Thread.sleep(200);
} catch (InterruptedException e) {
}
++i;
}
if (!pongReceived) {
Log.d("xmppService",account.getJid()+" no pong after "+timeout+" seconds");
reconnectAccount(account);
}
}
}).start();
}
} }

View file

@ -42,8 +42,9 @@ public abstract class XmppActivity extends Activity {
protected void onStart() { protected void onStart() {
super.onStart(); super.onStart();
if (!xmppConnectionServiceBound) { if (!xmppConnectionServiceBound) {
startService(new Intent(this, XmppConnectionService.class));
Intent intent = new Intent(this, XmppConnectionService.class); Intent intent = new Intent(this, XmppConnectionService.class);
intent.setAction("ui");
startService(intent);
bindService(intent, mConnection, Context.BIND_AUTO_CREATE); bindService(intent, mConnection, Context.BIND_AUTO_CREATE);
} }
} }

View file

@ -29,9 +29,9 @@ import javax.net.ssl.X509TrustManager;
import org.json.JSONException; import org.json.JSONException;
import org.xmlpull.v1.XmlPullParserException; import org.xmlpull.v1.XmlPullParserException;
import android.content.IntentSender.SendIntentException;
import android.os.Bundle; import android.os.Bundle;
import android.os.PowerManager; import android.os.PowerManager;
import android.os.SystemClock;
import android.util.Log; import android.util.Log;
import eu.siacs.conversations.entities.Account; import eu.siacs.conversations.entities.Account;
import eu.siacs.conversations.utils.CryptoHelper; import eu.siacs.conversations.utils.CryptoHelper;
@ -72,6 +72,9 @@ public class XmppConnection implements Runnable {
private int stanzasReceived = 0; private int stanzasReceived = 0;
private int stanzasSent = 0; private int stanzasSent = 0;
public long lastPaketReceived = 0;
public long lastPingSent = 0;
private static final int PACKET_IQ = 0; private static final int PACKET_IQ = 0;
private static final int PACKET_MESSAGE = 1; private static final int PACKET_MESSAGE = 1;
private static final int PACKET_PRESENCE = 2; private static final int PACKET_PRESENCE = 2;
@ -214,6 +217,7 @@ public class XmppConnection implements Runnable {
tagWriter.writeStanzaAsync(ack); tagWriter.writeStanzaAsync(ack);
} else if (nextTag.isStart("a")) { } else if (nextTag.isStart("a")) {
Element ack = tagReader.readElement(nextTag); Element ack = tagReader.readElement(nextTag);
lastPaketReceived = SystemClock.elapsedRealtime();
int serverSequence = Integer.parseInt(ack.getAttribute("h")); int serverSequence = Integer.parseInt(ack.getAttribute("h"));
if (serverSequence>this.stanzasSent) { if (serverSequence>this.stanzasSent) {
this.stanzasSent = serverSequence; this.stanzasSent = serverSequence;
@ -265,6 +269,7 @@ public class XmppConnection implements Runnable {
nextTag = tagReader.readTag(); nextTag = tagReader.readTag();
} }
++stanzasReceived; ++stanzasReceived;
lastPaketReceived = SystemClock.elapsedRealtime();
return element; return element;
} }
@ -580,6 +585,7 @@ public class XmppConnection implements Runnable {
} }
private synchronized void sendPacket(final AbstractStanza packet, PacketReceived callback) { private synchronized void sendPacket(final AbstractStanza packet, PacketReceived callback) {
// TODO dont increment stanza count if packet = request packet or ack;
++stanzasSent; ++stanzasSent;
tagWriter.writeStanzaAsync(packet); tagWriter.writeStanzaAsync(packet);
if (callback != null) { if (callback != null) {
@ -590,6 +596,21 @@ public class XmppConnection implements Runnable {
} }
} }
public void sendPing() {
if (streamFeatures.hasChild("sm")) {
Log.d(LOGTAG,"sending r as ping");
tagWriter.writeStanzaAsync(new RequestPacket());
} else {
Log.d(LOGTAG,"sending iq as ping");
IqPacket iq = new IqPacket(IqPacket.TYPE_GET);
Element ping = new Element("ping");
iq.setAttribute("from",account.getFullJid());
ping.setAttribute("xmlns", "urn:xmpp:ping");
iq.addChild(ping);
this.sendIqPacket(iq, null);
}
}
public void setOnMessagePacketReceivedListener( public void setOnMessagePacketReceivedListener(
OnMessagePacketReceived listener) { OnMessagePacketReceived listener) {
this.messageListener = listener; this.messageListener = listener;