Shuyi Chen | d7955ce | 2013-05-22 14:51:55 -0700 | [diff] [blame] | 1 | /**
|
| 2 | * $Revision: 2408 $
|
| 3 | * $Date: 2004-11-02 20:53:30 -0300 (Tue, 02 Nov 2004) $
|
| 4 | *
|
| 5 | * Copyright 2003-2005 Jive Software.
|
| 6 | *
|
| 7 | * All rights reserved. Licensed under the Apache License, Version 2.0 (the "License");
|
| 8 | * you may not use this file except in compliance with the License.
|
| 9 | * You may obtain a copy of the License at
|
| 10 | *
|
| 11 | * http://www.apache.org/licenses/LICENSE-2.0
|
| 12 | *
|
| 13 | * Unless required by applicable law or agreed to in writing, software
|
| 14 | * distributed under the License is distributed on an "AS IS" BASIS,
|
| 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 16 | * See the License for the specific language governing permissions and
|
| 17 | * limitations under the License.
|
| 18 | */
|
| 19 |
|
| 20 | package org.jivesoftware.smack;
|
| 21 |
|
| 22 | import org.jivesoftware.smack.packet.Packet;
|
| 23 |
|
| 24 | /**
|
| 25 | * Provides a mechanism to intercept and modify packets that are going to be
|
| 26 | * sent to the server. PacketInterceptors are added to the {@link Connection}
|
| 27 | * together with a {@link org.jivesoftware.smack.filter.PacketFilter} so that only
|
| 28 | * certain packets are intercepted and processed by the interceptor.<p>
|
| 29 | *
|
| 30 | * This allows event-style programming -- every time a new packet is found,
|
| 31 | * the {@link #interceptPacket(Packet)} method will be called.
|
| 32 | *
|
| 33 | * @see Connection#addPacketInterceptor(PacketInterceptor, org.jivesoftware.smack.filter.PacketFilter)
|
| 34 | * @author Gaston Dombiak
|
| 35 | */
|
| 36 | public interface PacketInterceptor {
|
| 37 |
|
| 38 | /**
|
| 39 | * Process the packet that is about to be sent to the server. The intercepted
|
| 40 | * packet can be modified by the interceptor.<p>
|
| 41 | *
|
| 42 | * Interceptors are invoked using the same thread that requested the packet
|
| 43 | * to be sent, so it's very important that implementations of this method
|
| 44 | * not block for any extended period of time.
|
| 45 | *
|
| 46 | * @param packet the packet to is going to be sent to the server.
|
| 47 | */
|
| 48 | public void interceptPacket(Packet packet);
|
| 49 | }
|