001/** 002 * 003 * Copyright 2003-2005 Jive Software. 004 * 005 * Licensed under the Apache License, Version 2.0 (the "License"); 006 * you may not use this file except in compliance with the License. 007 * You may obtain a copy of the License at 008 * 009 * http://www.apache.org/licenses/LICENSE-2.0 010 * 011 * Unless required by applicable law or agreed to in writing, software 012 * distributed under the License is distributed on an "AS IS" BASIS, 013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 014 * See the License for the specific language governing permissions and 015 * limitations under the License. 016 */ 017 018package org.jivesoftware.smack; 019 020import org.jivesoftware.smack.packet.Packet; 021 022/** 023 * Provides a mechanism to intercept and modify packets that are going to be 024 * sent to the server. PacketInterceptors are added to the {@link XMPPConnection} 025 * together with a {@link org.jivesoftware.smack.filter.PacketFilter} so that only 026 * certain packets are intercepted and processed by the interceptor.<p> 027 * 028 * This allows event-style programming -- every time a new packet is found, 029 * the {@link #interceptPacket(Packet)} method will be called. 030 * 031 * @see XMPPConnection#addPacketInterceptor(PacketInterceptor, org.jivesoftware.smack.filter.PacketFilter) 032 * @author Gaston Dombiak 033 */ 034public interface PacketInterceptor { 035 036 /** 037 * Process the packet that is about to be sent to the server. The intercepted 038 * packet can be modified by the interceptor.<p> 039 * 040 * Interceptors are invoked using the same thread that requested the packet 041 * to be sent, so it's very important that implementations of this method 042 * not block for any extended period of time. 043 * 044 * @param packet the packet to is going to be sent to the server. 045 */ 046 public void interceptPacket(Packet packet); 047}