mirror of
https://codeberg.org/Mercury-IM/Smack
synced 2024-11-26 00:02:06 +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:
parent
63fabf78ed
commit
50cf7f42f3
3 changed files with 3 additions and 32 deletions
|
@ -16,15 +16,9 @@
|
||||||
*/
|
*/
|
||||||
package org.jivesoftware.smackx.bytestreams.ibb;
|
package org.jivesoftware.smackx.bytestreams.ibb;
|
||||||
|
|
||||||
import org.jivesoftware.smack.StanzaListener;
|
|
||||||
import org.jivesoftware.smack.SmackException.NotConnectedException;
|
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.AbstractIqRequestHandler;
|
||||||
import org.jivesoftware.smack.iqrequest.IQRequestHandler;
|
|
||||||
import org.jivesoftware.smack.packet.IQ;
|
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.Data;
|
||||||
import org.jivesoftware.smackx.bytestreams.ibb.packet.DataPacketExtension;
|
import org.jivesoftware.smackx.bytestreams.ibb.packet.DataPacketExtension;
|
||||||
|
|
||||||
|
@ -42,15 +36,11 @@ import org.jivesoftware.smackx.bytestreams.ibb.packet.DataPacketExtension;
|
||||||
*
|
*
|
||||||
* @author Henning Staib
|
* @author Henning Staib
|
||||||
*/
|
*/
|
||||||
class DataListener extends AbstractIqRequestHandler implements StanzaListener, IQRequestHandler {
|
class DataListener extends AbstractIqRequestHandler {
|
||||||
|
|
||||||
/* manager containing the listeners and the XMPP connection */
|
/* manager containing the listeners and the XMPP connection */
|
||||||
private final InBandBytestreamManager manager;
|
private final InBandBytestreamManager manager;
|
||||||
|
|
||||||
/* packet filter for all In-Band Bytestream data packets */
|
|
||||||
private final StanzaFilter dataFilter = new AndFilter(
|
|
||||||
new StanzaTypeFilter(Data.class));
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor.
|
* Constructor.
|
||||||
*
|
*
|
||||||
|
@ -61,24 +51,6 @@ class DataListener extends AbstractIqRequestHandler implements StanzaListener, I
|
||||||
this.manager = manager;
|
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
|
@Override
|
||||||
public IQ handleIQRequest(IQ iqRequest) {
|
public IQ handleIQRequest(IQ iqRequest) {
|
||||||
Data data = (Data) iqRequest;
|
Data data = (Data) iqRequest;
|
||||||
|
|
|
@ -214,7 +214,6 @@ public class InBandBytestreamManager implements BytestreamManager {
|
||||||
|
|
||||||
// register bytestream data packet listener
|
// register bytestream data packet listener
|
||||||
this.dataListener = new DataListener(this);
|
this.dataListener = new DataListener(this);
|
||||||
this.connection.addSyncStanzaListener(this.dataListener, this.dataListener.getFilter());
|
|
||||||
connection.registerIQRequestHandler(dataListener);
|
connection.registerIQRequestHandler(dataListener);
|
||||||
|
|
||||||
// register bytestream close packet listener
|
// register bytestream close packet listener
|
||||||
|
@ -543,7 +542,7 @@ public class InBandBytestreamManager implements BytestreamManager {
|
||||||
|
|
||||||
// remove all listeners registered by this manager
|
// remove all listeners registered by this manager
|
||||||
connection.unregisterIQRequestHandler(initiationListener);
|
connection.unregisterIQRequestHandler(initiationListener);
|
||||||
this.connection.removeSyncStanzaListener(this.dataListener);
|
connection.unregisterIQRequestHandler(dataListener);
|
||||||
connection.unregisterIQRequestHandler(closeListener);
|
connection.unregisterIQRequestHandler(closeListener);
|
||||||
|
|
||||||
// shutdown threads
|
// shutdown threads
|
||||||
|
|
|
@ -63,7 +63,7 @@ public class DataListenerTest {
|
||||||
data.setFrom(initiatorJID);
|
data.setFrom(initiatorJID);
|
||||||
data.setTo(targetJID);
|
data.setTo(targetJID);
|
||||||
|
|
||||||
dataListener.processPacket(data);
|
dataListener.handleIQRequest(data);
|
||||||
|
|
||||||
// wait because packet is processed in an extra thread
|
// wait because packet is processed in an extra thread
|
||||||
Thread.sleep(200);
|
Thread.sleep(200);
|
||||||
|
|
Loading…
Reference in a new issue