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