synchronize packetCallbacks
This commit is contained in:
parent
c082066118
commit
51a2645349
|
@ -152,7 +152,6 @@ public class XmppConnection implements Runnable {
|
||||||
shouldAuthenticate = shouldBind = !account.isOptionSet(Account.OPTION_REGISTER);
|
shouldAuthenticate = shouldBind = !account.isOptionSet(Account.OPTION_REGISTER);
|
||||||
tagReader = new XmlReader(wakeLock);
|
tagReader = new XmlReader(wakeLock);
|
||||||
tagWriter = new TagWriter();
|
tagWriter = new TagWriter();
|
||||||
packetCallbacks.clear();
|
|
||||||
this.changeStatus(Account.State.CONNECTING);
|
this.changeStatus(Account.State.CONNECTING);
|
||||||
if (DNSHelper.isIp(account.getServer().toString())) {
|
if (DNSHelper.isIp(account.getServer().toString())) {
|
||||||
socket = new Socket();
|
socket = new Socket();
|
||||||
|
@ -489,6 +488,7 @@ public class XmppConnection implements Runnable {
|
||||||
this.jingleListener.onJinglePacketReceived(account,(JinglePacket) packet);
|
this.jingleListener.onJinglePacketReceived(account,(JinglePacket) packet);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
synchronized (this.packetCallbacks) {
|
||||||
if (packetCallbacks.containsKey(packet.getId())) {
|
if (packetCallbacks.containsKey(packet.getId())) {
|
||||||
final Pair<IqPacket, OnIqPacketReceived> packetCallbackDuple = packetCallbacks.get(packet.getId());
|
final Pair<IqPacket, OnIqPacketReceived> packetCallbackDuple = packetCallbacks.get(packet.getId());
|
||||||
// Packets to the server should have responses from the server
|
// Packets to the server should have responses from the server
|
||||||
|
@ -512,6 +512,7 @@ public class XmppConnection implements Runnable {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void processMessage(final Tag currentTag) throws XmlPullParserException, IOException {
|
private void processMessage(final Tag currentTag) throws XmlPullParserException, IOException {
|
||||||
final MessagePacket packet = (MessagePacket) processPacket(currentTag,PACKET_MESSAGE);
|
final MessagePacket packet = (MessagePacket) processPacket(currentTag,PACKET_MESSAGE);
|
||||||
|
@ -741,6 +742,7 @@ public class XmppConnection implements Runnable {
|
||||||
private void clearIqCallbacks() {
|
private void clearIqCallbacks() {
|
||||||
Log.d(Config.LOGTAG, account.getJid().toBareJid() + ": clearing iq iq callbacks");
|
Log.d(Config.LOGTAG, account.getJid().toBareJid() + ": clearing iq iq callbacks");
|
||||||
final IqPacket failurePacket = new IqPacket(IqPacket.TYPE.ERROR);
|
final IqPacket failurePacket = new IqPacket(IqPacket.TYPE.ERROR);
|
||||||
|
synchronized (this.packetCallbacks) {
|
||||||
Iterator<Entry<String, Pair<IqPacket, OnIqPacketReceived>>> iterator = this.packetCallbacks.entrySet().iterator();
|
Iterator<Entry<String, Pair<IqPacket, OnIqPacketReceived>>> iterator = this.packetCallbacks.entrySet().iterator();
|
||||||
while (iterator.hasNext()) {
|
while (iterator.hasNext()) {
|
||||||
Entry<String, Pair<IqPacket, OnIqPacketReceived>> entry = iterator.next();
|
Entry<String, Pair<IqPacket, OnIqPacketReceived>> entry = iterator.next();
|
||||||
|
@ -748,6 +750,7 @@ public class XmppConnection implements Runnable {
|
||||||
iterator.remove();
|
iterator.remove();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void sendStartSession() {
|
private void sendStartSession() {
|
||||||
final IqPacket startSession = new IqPacket(IqPacket.TYPE.SET);
|
final IqPacket startSession = new IqPacket(IqPacket.TYPE.SET);
|
||||||
|
@ -917,8 +920,10 @@ public class XmppConnection implements Runnable {
|
||||||
packet.setAttribute("id", id);
|
packet.setAttribute("id", id);
|
||||||
}
|
}
|
||||||
if (callback != null) {
|
if (callback != null) {
|
||||||
|
synchronized (this.packetCallbacks) {
|
||||||
packetCallbacks.put(packet.getId(), new Pair<>(packet, callback));
|
packetCallbacks.put(packet.getId(), new Pair<>(packet, callback));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
this.sendPacket(packet);
|
this.sendPacket(packet);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue