001/**
002 *
003 * Copyright 2003-2006 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 */
017package org.jivesoftware.smackx.jingleold.listeners;
018
019import org.jivesoftware.smack.SmackException.NoResponseException;
020import org.jivesoftware.smack.SmackException.NotConnectedException;
021import org.jivesoftware.smack.XMPPException;
022import org.jivesoftware.smack.XMPPException.XMPPErrorException;
023
024import org.jivesoftware.smackx.jingleold.nat.TransportCandidate;
025
026/**
027 * Interface for listening to transport events.
028 *
029 * @author Thiago Camargo
030 */
031public interface JingleTransportListener extends JingleListener {
032
033    /**
034     * Notification that the transport has been established.
035     *
036     * @param local  The transport candidate that has been used for listening
037     *               in the local machine
038     * @param remote The transport candidate that has been used for
039     *               transmitting to the remote machine
040     * @throws NotConnectedException if the XMPP connection is not connected.
041     * @throws InterruptedException if the calling thread was interrupted.
042     * @throws XMPPErrorException if there was an XMPP error returned.
043     * @throws NoResponseException if there was no response from the remote entity.
044     */
045    void transportEstablished(TransportCandidate local,
046                                     TransportCandidate remote) throws NotConnectedException, InterruptedException, NoResponseException, XMPPErrorException;
047
048    /**
049     * Notification that a transport must be cancelled.
050     *
051     * @param cand The transport candidate that must be cancelled. A value
052     *             of "null" means all the transports for this session.
053     */
054    void transportClosed(TransportCandidate cand);
055
056    /**
057     * Notification that the transport was closed due to an exception.
058     *
059     * @param e the exception.
060     */
061    void transportClosedOnError(XMPPException e);
062}
063