1
0
Fork 0
mirror of https://codeberg.org/Mercury-IM/Smack synced 2024-12-26 14:17:57 +01:00

DataListener is no longer a StanzaListener

it's just an IqRequestHandler. So remove the previous code related to it
being a stanza listener.
This commit is contained in:
Florian Schmaus 2015-03-02 15:48:43 +01:00
parent 63fabf78ed
commit 50cf7f42f3
3 changed files with 3 additions and 32 deletions

View file

@ -16,15 +16,9 @@
*/
package org.jivesoftware.smackx.bytestreams.ibb;
import org.jivesoftware.smack.StanzaListener;
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;
@ -42,15 +36,11 @@ import org.jivesoftware.smackx.bytestreams.ibb.packet.DataPacketExtension;
*
* @author Henning Staib
*/
class DataListener extends AbstractIqRequestHandler implements StanzaListener, IQRequestHandler {
class DataListener extends AbstractIqRequestHandler {
/* manager containing the listeners and the XMPP connection */
private final InBandBytestreamManager manager;
/* packet filter for all In-Band Bytestream data packets */
private final StanzaFilter dataFilter = new AndFilter(
new StanzaTypeFilter(Data.class));
/**
* Constructor.
*
@ -61,24 +51,6 @@ class DataListener extends AbstractIqRequestHandler implements StanzaListener, I
this.manager = manager;
}
public void processPacket(Stanza packet) throws NotConnectedException {
Data data = (Data) packet;
InBandBytestreamSession ibbSession = this.manager.getSessions().get(
data.getDataPacketExtension().getSessionID());
if (ibbSession == null) {
this.manager.replyItemNotFoundPacket(data);
}
}
/**
* Returns the packet filter for In-Band Bytestream data packets.
*
* @return the packet filter for In-Band Bytestream data packets
*/
protected StanzaFilter getFilter() {
return this.dataFilter;
}
@Override
public IQ handleIQRequest(IQ iqRequest) {
Data data = (Data) iqRequest;

View file

@ -214,7 +214,6 @@ 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
@ -543,7 +542,7 @@ public class InBandBytestreamManager implements BytestreamManager {
// remove all listeners registered by this manager
connection.unregisterIQRequestHandler(initiationListener);
this.connection.removeSyncStanzaListener(this.dataListener);
connection.unregisterIQRequestHandler(dataListener);
connection.unregisterIQRequestHandler(closeListener);
// shutdown threads

View file

@ -63,7 +63,7 @@ public class DataListenerTest {
data.setFrom(initiatorJID);
data.setTo(targetJID);
dataListener.processPacket(data);
dataListener.handleIQRequest(data);
// wait because packet is processed in an extra thread
Thread.sleep(200);