2003-01-13 17:58:47 +01:00
|
|
|
/**
|
|
|
|
*
|
2007-02-12 01:59:05 +01:00
|
|
|
* Copyright 2003-2007 Jive Software.
|
2003-01-13 17:58:47 +01:00
|
|
|
*
|
2014-02-17 18:57:38 +01:00
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
2004-11-03 00:53:30 +01:00
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
2003-01-13 17:58:47 +01:00
|
|
|
*
|
2004-11-03 00:53:30 +01:00
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
2003-01-13 17:58:47 +01:00
|
|
|
*
|
2004-11-03 00:53:30 +01:00
|
|
|
* 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.
|
2003-01-13 17:58:47 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
package org.jivesoftware.smack;
|
|
|
|
|
2014-03-19 14:22:20 +01:00
|
|
|
import org.jivesoftware.smack.SmackException.NotConnectedException;
|
2003-01-13 17:58:47 +01:00
|
|
|
import org.jivesoftware.smack.packet.Packet;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 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(Packet)} 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.
|
2014-10-12 19:19:44 +02:00
|
|
|
* <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.PacketFilter)}
|
|
|
|
* </p>
|
2003-01-13 17:58:47 +01:00
|
|
|
*
|
2014-03-10 09:45:50 +01:00
|
|
|
* @see XMPPConnection#addPacketListener(PacketListener, org.jivesoftware.smack.filter.PacketFilter)
|
2003-01-13 17:58:47 +01:00
|
|
|
* @author Matt Tucker
|
|
|
|
*/
|
|
|
|
public interface PacketListener {
|
|
|
|
|
|
|
|
/**
|
2014-10-12 19:19:44 +02:00
|
|
|
* Process the next packet sent to this packet listener.
|
|
|
|
* <p>
|
2003-09-18 22:38:12 +02:00
|
|
|
* 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.
|
2014-10-12 19:19:44 +02:00
|
|
|
* </p>
|
2003-01-13 17:58:47 +01:00
|
|
|
*
|
|
|
|
* @param packet the packet to process.
|
|
|
|
*/
|
2014-03-19 14:22:20 +01:00
|
|
|
public void processPacket(Packet packet) throws NotConnectedException;
|
2003-01-13 17:58:47 +01:00
|
|
|
|
|
|
|
}
|