mirror of
https://codeberg.org/Mercury-IM/Smack
synced 2025-09-10 18:59:41 +02:00
Rename PacketListener to StanzaListener
and add the PacketListener as deprecated interface.
This commit is contained in:
parent
d4a6d8e653
commit
75ec271c6c
40 changed files with 305 additions and 279 deletions
|
@ -131,26 +131,26 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
|
|||
/**
|
||||
* List of PacketListeners that will be notified synchronously when a new packet was received.
|
||||
*/
|
||||
private final Map<PacketListener, ListenerWrapper> syncRecvListeners = new LinkedHashMap<>();
|
||||
private final Map<StanzaListener, ListenerWrapper> syncRecvListeners = new LinkedHashMap<>();
|
||||
|
||||
/**
|
||||
* List of PacketListeners that will be notified asynchronously when a new packet was received.
|
||||
*/
|
||||
private final Map<PacketListener, ListenerWrapper> asyncRecvListeners = new LinkedHashMap<>();
|
||||
private final Map<StanzaListener, ListenerWrapper> asyncRecvListeners = new LinkedHashMap<>();
|
||||
|
||||
/**
|
||||
* List of PacketListeners that will be notified when a new packet was sent.
|
||||
*/
|
||||
private final Map<PacketListener, ListenerWrapper> sendListeners =
|
||||
new HashMap<PacketListener, ListenerWrapper>();
|
||||
private final Map<StanzaListener, ListenerWrapper> sendListeners =
|
||||
new HashMap<StanzaListener, ListenerWrapper>();
|
||||
|
||||
/**
|
||||
* List of PacketListeners that will be notified when a new packet is about to be
|
||||
* sent to the server. These interceptors may modify the packet before it is being
|
||||
* actually sent to the server.
|
||||
*/
|
||||
private final Map<PacketListener, InterceptorWrapper> interceptors =
|
||||
new HashMap<PacketListener, InterceptorWrapper>();
|
||||
private final Map<StanzaListener, InterceptorWrapper> interceptors =
|
||||
new HashMap<StanzaListener, InterceptorWrapper>();
|
||||
|
||||
protected final Lock connectionLock = new ReentrantLock();
|
||||
|
||||
|
@ -759,18 +759,18 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
|
|||
|
||||
@Override
|
||||
@Deprecated
|
||||
public void addPacketListener(PacketListener packetListener, StanzaFilter packetFilter) {
|
||||
addAsyncPacketListener(packetListener, packetFilter);
|
||||
public void addPacketListener(StanzaListener packetListener, StanzaFilter packetFilter) {
|
||||
addAsyncStanzaListener(packetListener, packetFilter);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public boolean removePacketListener(PacketListener packetListener) {
|
||||
return removeAsyncPacketListener(packetListener);
|
||||
public boolean removePacketListener(StanzaListener packetListener) {
|
||||
return removeAsyncStanzaListener(packetListener);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addSyncPacketListener(PacketListener packetListener, StanzaFilter packetFilter) {
|
||||
public void addSyncStanzaListener(StanzaListener packetListener, StanzaFilter packetFilter) {
|
||||
if (packetListener == null) {
|
||||
throw new NullPointerException("Packet listener is null.");
|
||||
}
|
||||
|
@ -781,14 +781,14 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean removeSyncPacketListener(PacketListener packetListener) {
|
||||
public boolean removeSyncStanzaListener(StanzaListener packetListener) {
|
||||
synchronized (syncRecvListeners) {
|
||||
return syncRecvListeners.remove(packetListener) != null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addAsyncPacketListener(PacketListener packetListener, StanzaFilter packetFilter) {
|
||||
public void addAsyncStanzaListener(StanzaListener packetListener, StanzaFilter packetFilter) {
|
||||
if (packetListener == null) {
|
||||
throw new NullPointerException("Packet listener is null.");
|
||||
}
|
||||
|
@ -799,14 +799,14 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean removeAsyncPacketListener(PacketListener packetListener) {
|
||||
public boolean removeAsyncStanzaListener(StanzaListener packetListener) {
|
||||
synchronized (asyncRecvListeners) {
|
||||
return asyncRecvListeners.remove(packetListener) != null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addPacketSendingListener(PacketListener packetListener, StanzaFilter packetFilter) {
|
||||
public void addPacketSendingListener(StanzaListener packetListener, StanzaFilter packetFilter) {
|
||||
if (packetListener == null) {
|
||||
throw new NullPointerException("Packet listener is null.");
|
||||
}
|
||||
|
@ -817,7 +817,7 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void removePacketSendingListener(PacketListener packetListener) {
|
||||
public void removePacketSendingListener(StanzaListener packetListener) {
|
||||
synchronized (sendListeners) {
|
||||
sendListeners.remove(packetListener);
|
||||
}
|
||||
|
@ -833,7 +833,7 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
|
|||
*/
|
||||
@SuppressWarnings("javadoc")
|
||||
protected void firePacketSendingListeners(final Stanza packet) {
|
||||
final List<PacketListener> listenersToNotify = new LinkedList<PacketListener>();
|
||||
final List<StanzaListener> listenersToNotify = new LinkedList<StanzaListener>();
|
||||
synchronized (sendListeners) {
|
||||
for (ListenerWrapper listenerWrapper : sendListeners.values()) {
|
||||
if (listenerWrapper.filterMatches(packet)) {
|
||||
|
@ -848,7 +848,7 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
|
|||
asyncGo(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
for (PacketListener listener : listenersToNotify) {
|
||||
for (StanzaListener listener : listenersToNotify) {
|
||||
try {
|
||||
listener.processPacket(packet);
|
||||
}
|
||||
|
@ -861,7 +861,7 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void addPacketInterceptor(PacketListener packetInterceptor,
|
||||
public void addPacketInterceptor(StanzaListener packetInterceptor,
|
||||
StanzaFilter packetFilter) {
|
||||
if (packetInterceptor == null) {
|
||||
throw new NullPointerException("Packet interceptor is null.");
|
||||
|
@ -873,7 +873,7 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void removePacketInterceptor(PacketListener packetInterceptor) {
|
||||
public void removePacketInterceptor(StanzaListener packetInterceptor) {
|
||||
synchronized (interceptors) {
|
||||
interceptors.remove(packetInterceptor);
|
||||
}
|
||||
|
@ -888,7 +888,7 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
|
|||
* @param packet the packet that is going to be sent to the server
|
||||
*/
|
||||
private void firePacketInterceptors(Stanza packet) {
|
||||
List<PacketListener> interceptorsToInvoke = new LinkedList<PacketListener>();
|
||||
List<StanzaListener> interceptorsToInvoke = new LinkedList<StanzaListener>();
|
||||
synchronized (interceptors) {
|
||||
for (InterceptorWrapper interceptorWrapper : interceptors.values()) {
|
||||
if (interceptorWrapper.filterMatches(packet)) {
|
||||
|
@ -896,7 +896,7 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
|
|||
}
|
||||
}
|
||||
}
|
||||
for (PacketListener interceptor : interceptorsToInvoke) {
|
||||
for (StanzaListener interceptor : interceptorsToInvoke) {
|
||||
try {
|
||||
interceptor.processPacket(packet);
|
||||
} catch (Exception e) {
|
||||
|
@ -1107,7 +1107,7 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
|
|||
// First handle the async recv listeners. Note that this code is very similar to what follows a few lines below,
|
||||
// the only difference is that asyncRecvListeners is used here and that the packet listeners are started in
|
||||
// their own thread.
|
||||
final Collection<PacketListener> listenersToNotify = new LinkedList<PacketListener>();
|
||||
final Collection<StanzaListener> listenersToNotify = new LinkedList<StanzaListener>();
|
||||
synchronized (asyncRecvListeners) {
|
||||
for (ListenerWrapper listenerWrapper : asyncRecvListeners.values()) {
|
||||
if (listenerWrapper.filterMatches(packet)) {
|
||||
|
@ -1116,7 +1116,7 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
|
|||
}
|
||||
}
|
||||
|
||||
for (final PacketListener listener : listenersToNotify) {
|
||||
for (final StanzaListener listener : listenersToNotify) {
|
||||
asyncGo(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
|
@ -1149,7 +1149,7 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
|
|||
singleThreadedExecutorService.execute(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
for (PacketListener listener : listenersToNotify) {
|
||||
for (StanzaListener listener : listenersToNotify) {
|
||||
try {
|
||||
listener.processPacket(packet);
|
||||
} catch(NotConnectedException e) {
|
||||
|
@ -1243,7 +1243,7 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
|
|||
*/
|
||||
protected static class ListenerWrapper {
|
||||
|
||||
private final PacketListener packetListener;
|
||||
private final StanzaListener packetListener;
|
||||
private final StanzaFilter packetFilter;
|
||||
|
||||
/**
|
||||
|
@ -1252,7 +1252,7 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
|
|||
* @param packetListener the packet listener.
|
||||
* @param packetFilter the associated filter or null if it listen for all packets.
|
||||
*/
|
||||
public ListenerWrapper(PacketListener packetListener, StanzaFilter packetFilter) {
|
||||
public ListenerWrapper(StanzaListener packetListener, StanzaFilter packetFilter) {
|
||||
this.packetListener = packetListener;
|
||||
this.packetFilter = packetFilter;
|
||||
}
|
||||
|
@ -1261,7 +1261,7 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
|
|||
return packetFilter == null || packetFilter.accept(packet);
|
||||
}
|
||||
|
||||
public PacketListener getListener() {
|
||||
public StanzaListener getListener() {
|
||||
return packetListener;
|
||||
}
|
||||
}
|
||||
|
@ -1271,7 +1271,7 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
|
|||
*/
|
||||
protected static class InterceptorWrapper {
|
||||
|
||||
private final PacketListener packetInterceptor;
|
||||
private final StanzaListener packetInterceptor;
|
||||
private final StanzaFilter packetFilter;
|
||||
|
||||
/**
|
||||
|
@ -1280,7 +1280,7 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
|
|||
* @param packetInterceptor the interceptor.
|
||||
* @param packetFilter the associated filter or null if it intercepts all packets.
|
||||
*/
|
||||
public InterceptorWrapper(PacketListener packetInterceptor, StanzaFilter packetFilter) {
|
||||
public InterceptorWrapper(StanzaListener packetInterceptor, StanzaFilter packetFilter) {
|
||||
this.packetInterceptor = packetInterceptor;
|
||||
this.packetFilter = packetFilter;
|
||||
}
|
||||
|
@ -1289,7 +1289,7 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
|
|||
return packetFilter == null || packetFilter.accept(packet);
|
||||
}
|
||||
|
||||
public PacketListener getInterceptor() {
|
||||
public StanzaListener getInterceptor() {
|
||||
return packetInterceptor;
|
||||
}
|
||||
}
|
||||
|
@ -1417,13 +1417,13 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
|
|||
|
||||
@Override
|
||||
public void sendStanzaWithResponseCallback(Stanza stanza, StanzaFilter replyFilter,
|
||||
PacketListener callback) throws NotConnectedException {
|
||||
StanzaListener callback) throws NotConnectedException {
|
||||
sendStanzaWithResponseCallback(stanza, replyFilter, callback, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendStanzaWithResponseCallback(Stanza stanza, StanzaFilter replyFilter,
|
||||
PacketListener callback, ExceptionCallback exceptionCallback)
|
||||
StanzaListener callback, ExceptionCallback exceptionCallback)
|
||||
throws NotConnectedException {
|
||||
sendStanzaWithResponseCallback(stanza, replyFilter, callback, exceptionCallback,
|
||||
getPacketReplyTimeout());
|
||||
|
@ -1431,7 +1431,7 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
|
|||
|
||||
@Override
|
||||
public void sendStanzaWithResponseCallback(Stanza stanza, final StanzaFilter replyFilter,
|
||||
final PacketListener callback, final ExceptionCallback exceptionCallback,
|
||||
final StanzaListener callback, final ExceptionCallback exceptionCallback,
|
||||
long timeout) throws NotConnectedException {
|
||||
Objects.requireNonNull(stanza, "stanza must not be null");
|
||||
// While Smack allows to add PacketListeners with a PacketFilter value of 'null', we
|
||||
|
@ -1439,7 +1439,7 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
|
|||
Objects.requireNonNull(replyFilter, "replyFilter must not be null");
|
||||
Objects.requireNonNull(callback, "callback must not be null");
|
||||
|
||||
final PacketListener packetListener = new PacketListener() {
|
||||
final StanzaListener packetListener = new StanzaListener() {
|
||||
@Override
|
||||
public void processPacket(Stanza packet) throws NotConnectedException {
|
||||
try {
|
||||
|
@ -1452,14 +1452,14 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
|
|||
}
|
||||
}
|
||||
finally {
|
||||
removeAsyncPacketListener(this);
|
||||
removeAsyncStanzaListener(this);
|
||||
}
|
||||
}
|
||||
};
|
||||
removeCallbacksService.schedule(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
boolean removed = removeAsyncPacketListener(packetListener);
|
||||
boolean removed = removeAsyncStanzaListener(packetListener);
|
||||
// If the packetListener got removed, then it was never run and
|
||||
// we never received a response, inform the exception callback
|
||||
if (removed && exceptionCallback != null) {
|
||||
|
@ -1467,24 +1467,24 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
|
|||
}
|
||||
}
|
||||
}, timeout, TimeUnit.MILLISECONDS);
|
||||
addAsyncPacketListener(packetListener, replyFilter);
|
||||
addAsyncStanzaListener(packetListener, replyFilter);
|
||||
sendPacket(stanza);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendIqWithResponseCallback(IQ iqRequest, PacketListener callback)
|
||||
public void sendIqWithResponseCallback(IQ iqRequest, StanzaListener callback)
|
||||
throws NotConnectedException {
|
||||
sendIqWithResponseCallback(iqRequest, callback, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendIqWithResponseCallback(IQ iqRequest, PacketListener callback,
|
||||
public void sendIqWithResponseCallback(IQ iqRequest, StanzaListener callback,
|
||||
ExceptionCallback exceptionCallback) throws NotConnectedException {
|
||||
sendIqWithResponseCallback(iqRequest, callback, exceptionCallback, getPacketReplyTimeout());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendIqWithResponseCallback(IQ iqRequest, final PacketListener callback,
|
||||
public void sendIqWithResponseCallback(IQ iqRequest, final StanzaListener callback,
|
||||
final ExceptionCallback exceptionCallback, long timeout)
|
||||
throws NotConnectedException {
|
||||
StanzaFilter replyFilter = new IQReplyFilter(iqRequest, this);
|
||||
|
@ -1492,22 +1492,22 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void addOneTimeSyncCallback(final PacketListener callback, final StanzaFilter packetFilter) {
|
||||
final PacketListener packetListener = new PacketListener() {
|
||||
public void addOneTimeSyncCallback(final StanzaListener callback, final StanzaFilter packetFilter) {
|
||||
final StanzaListener packetListener = new StanzaListener() {
|
||||
@Override
|
||||
public void processPacket(Stanza packet) throws NotConnectedException {
|
||||
try {
|
||||
callback.processPacket(packet);
|
||||
} finally {
|
||||
removeSyncPacketListener(this);
|
||||
removeSyncStanzaListener(this);
|
||||
}
|
||||
}
|
||||
};
|
||||
addSyncPacketListener(packetListener, packetFilter);
|
||||
addSyncStanzaListener(packetListener, packetFilter);
|
||||
removeCallbacksService.schedule(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
removeSyncPacketListener(packetListener);
|
||||
removeSyncStanzaListener(packetListener);
|
||||
}
|
||||
}, getPacketReplyTimeout(), TimeUnit.MILLISECONDS);
|
||||
}
|
||||
|
|
|
@ -31,7 +31,7 @@ import org.jivesoftware.smack.packet.Stanza;
|
|||
* Provides a mechanism to collect packets into a result queue that pass a
|
||||
* specified filter. The collector lets you perform blocking and polling
|
||||
* operations on the result queue. So, a PacketCollector is more suitable to
|
||||
* use than a {@link PacketListener} when you need to wait for a specific
|
||||
* use than a {@link StanzaListener} when you need to wait for a specific
|
||||
* result.<p>
|
||||
*
|
||||
* Each packet collector will queue up a configured number of packets for processing before
|
||||
|
|
|
@ -17,37 +17,10 @@
|
|||
|
||||
package org.jivesoftware.smack;
|
||||
|
||||
import org.jivesoftware.smack.SmackException.NotConnectedException;
|
||||
import org.jivesoftware.smack.packet.Stanza;
|
||||
|
||||
/**
|
||||
* Provides a mechanism to listen for packets that pass a specified filter.
|
||||
* This allows event-style programming -- every time a new packet is found,
|
||||
* the {@link #processPacket(Stanza)} method will be called. This is the
|
||||
* opposite approach to the functionality provided by a {@link PacketCollector}
|
||||
* which lets you block while waiting for results.
|
||||
* <p>
|
||||
* Additionally you are able to intercept Packets that are going to be send and
|
||||
* make modifications to them. You can register a PacketListener as interceptor
|
||||
* by using {@link XMPPConnection#addPacketInterceptor(PacketListener,
|
||||
* org.jivesoftware.smack.filter.StanzaFilter)}
|
||||
* </p>
|
||||
*
|
||||
* @see XMPPConnection#addAsyncPacketListener(PacketListener, org.jivesoftware.smack.filter.StanzaFilter)
|
||||
* @author Matt Tucker
|
||||
* @deprecated use {@link StanzaListener} instead
|
||||
*/
|
||||
public interface PacketListener {
|
||||
|
||||
/**
|
||||
* Process the next packet sent to this packet listener.
|
||||
* <p>
|
||||
* A single thread is responsible for invoking all listeners, so
|
||||
* it's very important that implementations of this method not block
|
||||
* for any extended period of time.
|
||||
* </p>
|
||||
*
|
||||
* @param packet the packet to process.
|
||||
*/
|
||||
public void processPacket(Stanza packet) throws NotConnectedException;
|
||||
@Deprecated
|
||||
public interface PacketListener extends StanzaListener {
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,53 @@
|
|||
/**
|
||||
*
|
||||
* Copyright 2003-2007 Jive Software.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jivesoftware.smack;
|
||||
|
||||
import org.jivesoftware.smack.SmackException.NotConnectedException;
|
||||
import org.jivesoftware.smack.packet.Stanza;
|
||||
|
||||
/**
|
||||
* Provides a mechanism to listen for packets that pass a specified filter.
|
||||
* This allows event-style programming -- every time a new packet is found,
|
||||
* the {@link #processPacket(Stanza)} method will be called. This is the
|
||||
* opposite approach to the functionality provided by a {@link PacketCollector}
|
||||
* which lets you block while waiting for results.
|
||||
* <p>
|
||||
* Additionally you are able to intercept Packets that are going to be send and
|
||||
* make modifications to them. You can register a PacketListener as interceptor
|
||||
* by using {@link XMPPConnection#addPacketInterceptor(StanzaListener,
|
||||
* org.jivesoftware.smack.filter.StanzaFilter)}
|
||||
* </p>
|
||||
*
|
||||
* @see XMPPConnection#addAsyncStanzaListener(StanzaListener, org.jivesoftware.smack.filter.StanzaFilter)
|
||||
* @author Matt Tucker
|
||||
*/
|
||||
public interface StanzaListener {
|
||||
|
||||
/**
|
||||
* Process the next packet sent to this packet listener.
|
||||
* <p>
|
||||
* A single thread is responsible for invoking all listeners, so
|
||||
* it's very important that implementations of this method not block
|
||||
* for any extended period of time.
|
||||
* </p>
|
||||
*
|
||||
* @param packet the packet to process.
|
||||
*/
|
||||
public void processPacket(Stanza packet) throws NotConnectedException;
|
||||
|
||||
}
|
|
@ -204,7 +204,7 @@ public interface XMPPConnection {
|
|||
/**
|
||||
* Creates a new packet collector for this connection. A packet filter determines
|
||||
* which packets will be accumulated by the collector. A PacketCollector is
|
||||
* more suitable to use than a {@link PacketListener} when you need to wait for
|
||||
* more suitable to use than a {@link StanzaListener} when you need to wait for
|
||||
* a specific result.
|
||||
*
|
||||
* @param packetFilter the packet filter to use.
|
||||
|
@ -217,7 +217,7 @@ public interface XMPPConnection {
|
|||
/**
|
||||
* Creates a new packet collector for this connection. A packet filter
|
||||
* determines which packets will be accumulated by the collector. A
|
||||
* PacketCollector is more suitable to use than a {@link PacketListener}
|
||||
* PacketCollector is more suitable to use than a {@link StanzaListener}
|
||||
* when you need to wait for a specific result.
|
||||
* <p>
|
||||
* <b>Note:</b> If you send a Packet right after using this method, then
|
||||
|
@ -257,27 +257,27 @@ public interface XMPPConnection {
|
|||
* <p>
|
||||
* This method has been deprecated. It is important to differentiate between using an asynchronous packet listener
|
||||
* (preferred where possible) and a synchronous packet lister. Refer
|
||||
* {@link #addAsyncPacketListener(PacketListener, StanzaFilter)} and
|
||||
* {@link #addSyncPacketListener(PacketListener, StanzaFilter)} for more information.
|
||||
* {@link #addAsyncStanzaListener(StanzaListener, StanzaFilter)} and
|
||||
* {@link #addSyncStanzaListener(StanzaListener, StanzaFilter)} for more information.
|
||||
* </p>
|
||||
*
|
||||
* @param packetListener the packet listener to notify of new received packets.
|
||||
* @param packetFilter the packet filter to use.
|
||||
* @deprecated use {@link #addAsyncPacketListener(PacketListener, StanzaFilter)} or
|
||||
* {@link #addSyncPacketListener(PacketListener, StanzaFilter)}.
|
||||
* @deprecated use {@link #addAsyncStanzaListener(StanzaListener, StanzaFilter)} or
|
||||
* {@link #addSyncStanzaListener(StanzaListener, StanzaFilter)}.
|
||||
*/
|
||||
@Deprecated
|
||||
public void addPacketListener(PacketListener packetListener, StanzaFilter packetFilter);
|
||||
public void addPacketListener(StanzaListener packetListener, StanzaFilter packetFilter);
|
||||
|
||||
/**
|
||||
* Removes a packet listener for received packets from this connection.
|
||||
*
|
||||
* @param packetListener the packet listener to remove.
|
||||
* @return true if the packet listener was removed
|
||||
* @deprecated use {@link #removeAsyncPacketListener(PacketListener)} or {@link #removeSyncPacketListener(PacketListener)}.
|
||||
* @deprecated use {@link #removeAsyncStanzaListener(StanzaListener)} or {@link #removeSyncStanzaListener(StanzaListener)}.
|
||||
*/
|
||||
@Deprecated
|
||||
public boolean removePacketListener(PacketListener packetListener);
|
||||
public boolean removePacketListener(StanzaListener packetListener);
|
||||
|
||||
/**
|
||||
* Registers a <b>synchronous</b> packet listener with this connection. A packet listener will be invoked only when
|
||||
|
@ -286,17 +286,17 @@ public interface XMPPConnection {
|
|||
* <p>
|
||||
* <b>Important:</b> This packet listeners will be called in the same <i>single</i> thread that processes all
|
||||
* incoming stanzas. Only use this kind of packet filter if it does not perform any XMPP activity that waits for a
|
||||
* response. Consider using {@link #addAsyncPacketListener(PacketListener, StanzaFilter)} when possible, i.e. when
|
||||
* response. Consider using {@link #addAsyncStanzaListener(StanzaListener, StanzaFilter)} when possible, i.e. when
|
||||
* the invocation order doesn't have to be the same as the order of the arriving packets. If the order of the
|
||||
* arriving packets, consider using a {@link PacketCollector} when possible.
|
||||
* </p>
|
||||
*
|
||||
* @param packetListener the packet listener to notify of new received packets.
|
||||
* @param packetFilter the packet filter to use.
|
||||
* @see #addPacketInterceptor(PacketListener, StanzaFilter)
|
||||
* @see #addPacketInterceptor(StanzaListener, StanzaFilter)
|
||||
* @since 4.1
|
||||
*/
|
||||
public void addSyncPacketListener(PacketListener packetListener, StanzaFilter packetFilter);
|
||||
public void addSyncStanzaListener(StanzaListener packetListener, StanzaFilter packetFilter);
|
||||
|
||||
/**
|
||||
* Removes a packet listener for received packets from this connection.
|
||||
|
@ -305,24 +305,24 @@ public interface XMPPConnection {
|
|||
* @return true if the packet listener was removed
|
||||
* @since 4.1
|
||||
*/
|
||||
public boolean removeSyncPacketListener(PacketListener packetListener);
|
||||
public boolean removeSyncStanzaListener(StanzaListener packetListener);
|
||||
|
||||
/**
|
||||
* Registers an <b>asynchronous</b> packet listener with this connection. A packet listener will be invoked only
|
||||
* when an incoming packet is received. A packet filter determines which packets will be delivered to the listener.
|
||||
* If the same packet listener is added again with a different filter, only the new filter will be used.
|
||||
* <p>
|
||||
* Unlike {@link #addAsyncPacketListener(PacketListener, StanzaFilter)} packet listeners added with this method will be
|
||||
* Unlike {@link #addAsyncStanzaListener(StanzaListener, StanzaFilter)} packet listeners added with this method will be
|
||||
* invoked asynchronously in their own thread. Use this method if the order of the packet listeners must not depend
|
||||
* on the order how the stanzas where received.
|
||||
* </p>
|
||||
*
|
||||
* @param packetListener the packet listener to notify of new received packets.
|
||||
* @param packetFilter the packet filter to use.
|
||||
* @see #addPacketInterceptor(PacketListener, StanzaFilter)
|
||||
* @see #addPacketInterceptor(StanzaListener, StanzaFilter)
|
||||
* @since 4.1
|
||||
*/
|
||||
public void addAsyncPacketListener(PacketListener packetListener, StanzaFilter packetFilter);
|
||||
public void addAsyncStanzaListener(StanzaListener packetListener, StanzaFilter packetFilter);
|
||||
|
||||
/**
|
||||
* Removes an <b>asynchronous</b> packet listener for received packets from this connection.
|
||||
|
@ -331,7 +331,7 @@ public interface XMPPConnection {
|
|||
* @return true if the packet listener was removed
|
||||
* @since 4.1
|
||||
*/
|
||||
public boolean removeAsyncPacketListener(PacketListener packetListener);
|
||||
public boolean removeAsyncStanzaListener(StanzaListener packetListener);
|
||||
|
||||
/**
|
||||
* Registers a packet listener with this connection. The listener will be
|
||||
|
@ -344,14 +344,14 @@ public interface XMPPConnection {
|
|||
* @param packetListener the packet listener to notify of sent packets.
|
||||
* @param packetFilter the packet filter to use.
|
||||
*/
|
||||
public void addPacketSendingListener(PacketListener packetListener, StanzaFilter packetFilter);
|
||||
public void addPacketSendingListener(StanzaListener packetListener, StanzaFilter packetFilter);
|
||||
|
||||
/**
|
||||
* Removes a packet listener for sending packets from this connection.
|
||||
*
|
||||
* @param packetListener the packet listener to remove.
|
||||
*/
|
||||
public void removePacketSendingListener(PacketListener packetListener);
|
||||
public void removePacketSendingListener(StanzaListener packetListener);
|
||||
|
||||
/**
|
||||
* Registers a packet interceptor with this connection. The interceptor will be
|
||||
|
@ -360,19 +360,19 @@ public interface XMPPConnection {
|
|||
* will be delivered to the interceptor.
|
||||
*
|
||||
* <p>
|
||||
* NOTE: For a similar functionality on incoming packets, see {@link #addAsyncPacketListener(PacketListener, StanzaFilter)}.
|
||||
* NOTE: For a similar functionality on incoming packets, see {@link #addAsyncStanzaListener(StanzaListener, StanzaFilter)}.
|
||||
*
|
||||
* @param packetInterceptor the packet interceptor to notify of packets about to be sent.
|
||||
* @param packetFilter the packet filter to use.
|
||||
*/
|
||||
public void addPacketInterceptor(PacketListener packetInterceptor, StanzaFilter packetFilter);
|
||||
public void addPacketInterceptor(StanzaListener packetInterceptor, StanzaFilter packetFilter);
|
||||
|
||||
/**
|
||||
* Removes a packet interceptor.
|
||||
*
|
||||
* @param packetInterceptor the packet interceptor to remove.
|
||||
*/
|
||||
public void removePacketInterceptor(PacketListener packetInterceptor);
|
||||
public void removePacketInterceptor(StanzaListener packetInterceptor);
|
||||
|
||||
/**
|
||||
* Returns the current value of the reply timeout in milliseconds for request for this
|
||||
|
@ -464,7 +464,7 @@ public interface XMPPConnection {
|
|||
* @throws NotConnectedException
|
||||
*/
|
||||
public void sendStanzaWithResponseCallback(Stanza stanza, StanzaFilter replyFilter,
|
||||
PacketListener callback) throws NotConnectedException;
|
||||
StanzaListener callback) throws NotConnectedException;
|
||||
|
||||
/**
|
||||
* Send a stanza and wait asynchronously for a response by using <code>replyFilter</code>.
|
||||
|
@ -480,7 +480,7 @@ public interface XMPPConnection {
|
|||
* @param exceptionCallback the callback invoked if there is an exception (optional)
|
||||
* @throws NotConnectedException
|
||||
*/
|
||||
public void sendStanzaWithResponseCallback(Stanza stanza, StanzaFilter replyFilter, PacketListener callback,
|
||||
public void sendStanzaWithResponseCallback(Stanza stanza, StanzaFilter replyFilter, StanzaListener callback,
|
||||
ExceptionCallback exceptionCallback) throws NotConnectedException;
|
||||
|
||||
/**
|
||||
|
@ -499,7 +499,7 @@ public interface XMPPConnection {
|
|||
* @throws NotConnectedException
|
||||
*/
|
||||
public void sendStanzaWithResponseCallback(Stanza stanza, StanzaFilter replyFilter,
|
||||
final PacketListener callback, final ExceptionCallback exceptionCallback,
|
||||
final StanzaListener callback, final ExceptionCallback exceptionCallback,
|
||||
long timeout) throws NotConnectedException;
|
||||
|
||||
/**
|
||||
|
@ -511,7 +511,7 @@ public interface XMPPConnection {
|
|||
* @param callback the callback invoked if there is result response (required)
|
||||
* @throws NotConnectedException
|
||||
*/
|
||||
public void sendIqWithResponseCallback(IQ iqRequest, PacketListener callback) throws NotConnectedException;
|
||||
public void sendIqWithResponseCallback(IQ iqRequest, StanzaListener callback) throws NotConnectedException;
|
||||
|
||||
/**
|
||||
* Send a IQ stanza and invoke <code>callback</code> if there is a result of
|
||||
|
@ -526,7 +526,7 @@ public interface XMPPConnection {
|
|||
* @param exceptionCallback the callback invoked if there is an Exception optional
|
||||
* @throws NotConnectedException
|
||||
*/
|
||||
public void sendIqWithResponseCallback(IQ iqRequest, PacketListener callback,
|
||||
public void sendIqWithResponseCallback(IQ iqRequest, StanzaListener callback,
|
||||
ExceptionCallback exceptionCallback) throws NotConnectedException;
|
||||
|
||||
/**
|
||||
|
@ -543,7 +543,7 @@ public interface XMPPConnection {
|
|||
* @param timeout the timeout in milliseconds to wait for a response
|
||||
* @throws NotConnectedException
|
||||
*/
|
||||
public void sendIqWithResponseCallback(IQ iqRequest, final PacketListener callback,
|
||||
public void sendIqWithResponseCallback(IQ iqRequest, final StanzaListener callback,
|
||||
final ExceptionCallback exceptionCallback, long timeout)
|
||||
throws NotConnectedException;
|
||||
|
||||
|
@ -554,7 +554,7 @@ public interface XMPPConnection {
|
|||
* @param callback the callback invoked once the packet filter matches a stanza.
|
||||
* @param packetFilter the filter to match stanzas or null to match all.
|
||||
*/
|
||||
public void addOneTimeSyncCallback(PacketListener callback, StanzaFilter packetFilter);
|
||||
public void addOneTimeSyncCallback(StanzaListener callback, StanzaFilter packetFilter);
|
||||
|
||||
/**
|
||||
* Register an IQ request handler with this connection.
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
package org.jivesoftware.smack.debugger;
|
||||
|
||||
import org.jivesoftware.smack.ConnectionListener;
|
||||
import org.jivesoftware.smack.PacketListener;
|
||||
import org.jivesoftware.smack.StanzaListener;
|
||||
import org.jivesoftware.smack.XMPPConnection;
|
||||
import org.jivesoftware.smack.packet.Stanza;
|
||||
import org.jivesoftware.smack.util.ObservableReader;
|
||||
|
@ -35,7 +35,7 @@ public abstract class AbstractDebugger implements SmackDebugger {
|
|||
|
||||
private final XMPPConnection connection;
|
||||
|
||||
private final PacketListener listener;
|
||||
private final StanzaListener listener;
|
||||
private final ConnectionListener connListener;
|
||||
private final ReaderListener readerListener;
|
||||
private final WriterListener writerListener;
|
||||
|
@ -67,7 +67,7 @@ public abstract class AbstractDebugger implements SmackDebugger {
|
|||
// Create a thread that will listen for all incoming packets and write them to
|
||||
// the GUI. This is what we call "interpreted" packet data, since it's the packet
|
||||
// data as Smack sees it and not as it's coming in as raw XML.
|
||||
listener = new PacketListener() {
|
||||
listener = new StanzaListener() {
|
||||
public void processPacket(Stanza packet) {
|
||||
if (printInterpreted) {
|
||||
log("RCV PKT (" + connection.getConnectionCounter() + "): " + packet.toXML());
|
||||
|
@ -166,11 +166,11 @@ public abstract class AbstractDebugger implements SmackDebugger {
|
|||
return writer;
|
||||
}
|
||||
|
||||
public PacketListener getReaderListener() {
|
||||
public StanzaListener getReaderListener() {
|
||||
return listener;
|
||||
}
|
||||
|
||||
public PacketListener getWriterListener() {
|
||||
public StanzaListener getWriterListener() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@ package org.jivesoftware.smack.debugger;
|
|||
import java.io.Reader;
|
||||
import java.io.Writer;
|
||||
|
||||
import org.jivesoftware.smack.PacketListener;
|
||||
import org.jivesoftware.smack.StanzaListener;
|
||||
|
||||
/**
|
||||
* Interface that allows for implementing classes to debug XML traffic. That is a GUI window that
|
||||
|
@ -84,7 +84,7 @@ public interface SmackDebugger {
|
|||
* @return the PacketListener that will listen for all incoming packets and write them to
|
||||
* the GUI
|
||||
*/
|
||||
public abstract PacketListener getReaderListener();
|
||||
public abstract StanzaListener getReaderListener();
|
||||
|
||||
/**
|
||||
* Returns the thread that will listen for all outgoing packets and write them to the GUI.
|
||||
|
@ -92,5 +92,5 @@ public interface SmackDebugger {
|
|||
* @return the PacketListener that will listen for all sent packets and write them to
|
||||
* the GUI
|
||||
*/
|
||||
public abstract PacketListener getWriterListener();
|
||||
public abstract StanzaListener getWriterListener();
|
||||
}
|
||||
|
|
|
@ -41,7 +41,7 @@ package org.jivesoftware.smack.filter;
|
|||
* </pre>
|
||||
*
|
||||
* @see org.jivesoftware.smack.PacketCollector
|
||||
* @see org.jivesoftware.smack.PacketListener
|
||||
* @see org.jivesoftware.smack.StanzaListener
|
||||
* @author Matt Tucker
|
||||
* @deprecated use {@link StanzaFilter}
|
||||
*/
|
||||
|
|
|
@ -43,7 +43,7 @@ import org.jivesoftware.smack.packet.Stanza;
|
|||
* </pre>
|
||||
*
|
||||
* @see org.jivesoftware.smack.PacketCollector
|
||||
* @see org.jivesoftware.smack.PacketListener
|
||||
* @see org.jivesoftware.smack.StanzaListener
|
||||
* @author Matt Tucker
|
||||
*/
|
||||
public interface StanzaFilter {
|
||||
|
|
|
@ -19,11 +19,11 @@ package org.jivesoftware.smack.test.util;
|
|||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.jivesoftware.smack.PacketListener;
|
||||
import org.jivesoftware.smack.StanzaListener;
|
||||
import org.jivesoftware.smack.SmackException.NotConnectedException;
|
||||
import org.jivesoftware.smack.packet.Stanza;
|
||||
|
||||
public class WaitForPacketListener implements PacketListener {
|
||||
public class WaitForPacketListener implements StanzaListener {
|
||||
|
||||
private CountDownLatch latch = new CountDownLatch(1);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue