1
0
Fork 0
mirror of https://github.com/vanitasvitae/Smack.git synced 2024-12-22 18:48:00 +01:00

Fixed Data IQ packet receiving

Data packets where not received by the InBandByteStream due to a missing
IQRequestHandler

Conflicts:
	smack-extensions/src/main/java/org/jivesoftware/smackx/bytestreams/ibb/DataListener.java
	smack-extensions/src/main/java/org/jivesoftware/smackx/bytestreams/ibb/InBandBytestreamManager.java
	smack-extensions/src/main/java/org/jivesoftware/smackx/bytestreams/ibb/InBandBytestreamSession.java
This commit is contained in:
Anno van Vliet 2015-03-02 14:46:42 +01:00 committed by Florian Schmaus
parent 96bb37f924
commit 63fabf78ed
3 changed files with 35 additions and 2 deletions

View file

@ -21,8 +21,12 @@ import org.jivesoftware.smack.SmackException.NotConnectedException;
import org.jivesoftware.smack.filter.AndFilter;
import org.jivesoftware.smack.filter.StanzaFilter;
import org.jivesoftware.smack.filter.StanzaTypeFilter;
import org.jivesoftware.smack.iqrequest.AbstractIqRequestHandler;
import org.jivesoftware.smack.iqrequest.IQRequestHandler;
import org.jivesoftware.smack.packet.IQ;
import org.jivesoftware.smack.packet.Stanza;
import org.jivesoftware.smackx.bytestreams.ibb.packet.Data;
import org.jivesoftware.smackx.bytestreams.ibb.packet.DataPacketExtension;
/**
* DataListener handles all In-Band Bytestream IQ stanzas containing a data
@ -38,7 +42,7 @@ import org.jivesoftware.smackx.bytestreams.ibb.packet.Data;
*
* @author Henning Staib
*/
class DataListener implements StanzaListener {
class DataListener extends AbstractIqRequestHandler implements StanzaListener, IQRequestHandler {
/* manager containing the listeners and the XMPP connection */
private final InBandBytestreamManager manager;
@ -53,6 +57,7 @@ class DataListener implements StanzaListener {
* @param manager the In-Band Bytestream manager
*/
public DataListener(InBandBytestreamManager manager) {
super(DataPacketExtension.ELEMENT, DataPacketExtension.NAMESPACE, IQ.Type.set, Mode.async);
this.manager = manager;
}
@ -74,4 +79,23 @@ class DataListener implements StanzaListener {
return this.dataFilter;
}
@Override
public IQ handleIQRequest(IQ iqRequest) {
Data data = (Data) iqRequest;
InBandBytestreamSession ibbSession = this.manager.getSessions().get(
data.getDataPacketExtension().getSessionID());
try {
if (ibbSession == null) {
this.manager.replyItemNotFoundPacket(data);
}
else {
ibbSession.processIQPacket(data);
}
}
catch (NotConnectedException e) {
return null;
}
return null;
}
}

View file

@ -25,11 +25,11 @@ import java.util.Random;
import java.util.concurrent.ConcurrentHashMap;
import org.jivesoftware.smack.AbstractConnectionClosedListener;
import org.jivesoftware.smack.ConnectionCreationListener;
import org.jivesoftware.smack.SmackException;
import org.jivesoftware.smack.SmackException.NoResponseException;
import org.jivesoftware.smack.SmackException.NotConnectedException;
import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.ConnectionCreationListener;
import org.jivesoftware.smack.XMPPConnectionRegistry;
import org.jivesoftware.smack.XMPPException;
import org.jivesoftware.smack.XMPPException.XMPPErrorException;
@ -215,6 +215,7 @@ public class InBandBytestreamManager implements BytestreamManager {
// register bytestream data packet listener
this.dataListener = new DataListener(this);
this.connection.addSyncStanzaListener(this.dataListener, this.dataListener.getFilter());
connection.registerIQRequestHandler(dataListener);
// register bytestream close packet listener
this.closeListener = new CloseListener(this);

View file

@ -814,4 +814,12 @@ public class InBandBytestreamSession implements BytestreamSession {
}
/**
* @param data
* @throws NotConnectedException
*/
public void processIQPacket(Data data) throws NotConnectedException {
inputStream.dataPacketListener.processPacket(data);
}
}