java.lang.Object
org.jivesoftware.smack.packet.Stanza
org.jivesoftware.smack.packet.IQ
org.jivesoftware.smack.packet.SimpleIQ
org.jivesoftware.smackx.jingleold.nat.STUN
All Implemented Interfaces:
org.jivesoftware.smack.packet.Element, org.jivesoftware.smack.packet.IqView, org.jivesoftware.smack.packet.NamedElement, org.jivesoftware.smack.packet.StanzaView, org.jivesoftware.smack.packet.TopLevelStreamElement, org.jivesoftware.smack.packet.XmlElement, org.jivesoftware.smack.packet.XmlLangElement

public class STUN extends org.jivesoftware.smack.packet.SimpleIQ
STUN IQ Stanza used to request and retrieve a STUN server and port to make p2p connections easier. STUN is usually used by Jingle Media Transmission between two parties that are behind NAT. High Level Usage Example: STUN stun = STUN.getSTUNServer(connection);
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static class 
    IQProvider for RTP Bridge packets.
    static class 
    Provides easy abstract to store STUN Server Addresses and Ports.

    Nested classes/interfaces inherited from class org.jivesoftware.smack.packet.IQ

    org.jivesoftware.smack.packet.IQ.IQChildElementXmlStringBuilder, org.jivesoftware.smack.packet.IQ.ResponseType, org.jivesoftware.smack.packet.IQ.Type
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final String
    Element name of the stanza extension.
    static final String
    Element name of the stanza extension.
    static final String
    Namespace of the stanza extension.

    Fields inherited from class org.jivesoftware.smack.packet.IQ

    IQ_ELEMENT, QUERY_ELEMENT

    Fields inherited from class org.jivesoftware.smack.packet.Stanza

    DEFAULT_LANGUAGE, ITEM, language, TEXT
  • Constructor Summary

    Constructors
    Constructor
    Description
    Creates a STUN IQ.
  • Method Summary

    Modifier and Type
    Method
    Description
    Get Public Ip returned from the XMPP server.
    Get a list of STUN Servers recommended by the Server.
    static STUN
    getSTUNServer(org.jivesoftware.smack.XMPPConnection connection)
    Get a new STUN Server Address and port from the server.
    static boolean
    serviceAvailable(org.jivesoftware.smack.XMPPConnection connection)
    Check if the server support STUN Service.

    Methods inherited from class org.jivesoftware.smack.packet.SimpleIQ

    getIQChildElementBuilder

    Methods inherited from class org.jivesoftware.smack.packet.IQ

    createErrorResponse, createErrorResponse, createResultIQ, getChildElementName, getChildElementNamespace, getChildElementQName, getChildElementXML, getElementName, getType, setType, toString, toXML

    Methods inherited from class org.jivesoftware.smack.packet.Stanza

    addCommonAttributes, addExtension, addExtensions, appendErrorIfExists, getDefaultLanguage, getError, getExtension, getExtension, getExtensionElement, getExtensions, getExtensions, getExtensions, getExtensions, getExtensionsMap, getFrom, getLanguage, getNamespace, getStanzaId, getTo, hasExtension, hasExtension, hasStanzaIdSet, logCommonAttributes, overrideExtension, removeExtension, setError, setFrom, setNewStanzaId, setStanzaId, setTo, throwIfNoStanzaId

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait

    Methods inherited from interface org.jivesoftware.smack.packet.Element

    toXML, toXML

    Methods inherited from interface org.jivesoftware.smack.packet.IqView

    isRequestIQ, isResponseIQ

    Methods inherited from interface org.jivesoftware.smack.packet.StanzaView

    getError, getExtension, getExtension, getExtensions, getExtensions, getExtensions, getFrom, getStanzaId, getTo, hasExtension, hasExtension, hasExtension

    Methods inherited from interface org.jivesoftware.smack.packet.XmlElement

    getQName
  • Field Details

  • Constructor Details

    • STUN

      public STUN()
      Creates a STUN IQ.
  • Method Details

    • getServers

      public List<STUN.StunServerAddress> getServers()
      Get a list of STUN Servers recommended by the Server.
      Returns:
      the list of STUN servers
    • getPublicIp

      public String getPublicIp()
      Get Public Ip returned from the XMPP server.
      Returns:
      the public IP
    • getSTUNServer

      public static STUN getSTUNServer(org.jivesoftware.smack.XMPPConnection connection) throws org.jivesoftware.smack.SmackException.NotConnectedException, InterruptedException, org.jivesoftware.smack.SmackException.NoResponseException, org.jivesoftware.smack.XMPPException.XMPPErrorException
      Get a new STUN Server Address and port from the server. If a error occurs or the server don't support STUN Service, null is returned.
      Parameters:
      connection - TODO javadoc me please
      Returns:
      the STUN server address
      Throws:
      org.jivesoftware.smack.SmackException.NotConnectedException - if the XMPP connection is not connected.
      InterruptedException - if the calling thread was interrupted.
      org.jivesoftware.smack.XMPPException.XMPPErrorException - if there was an XMPP error returned.
      org.jivesoftware.smack.SmackException.NoResponseException - if there was no response from the remote entity.
    • serviceAvailable

      public static boolean serviceAvailable(org.jivesoftware.smack.XMPPConnection connection) throws org.jivesoftware.smack.XMPPException, org.jivesoftware.smack.SmackException, InterruptedException
      Check if the server support STUN Service.
      Parameters:
      connection - the connection
      Returns:
      true if the server support STUN
      Throws:
      org.jivesoftware.smack.SmackException - if Smack detected an exceptional situation.
      org.jivesoftware.smack.XMPPException - if an XMPP protocol error was received.
      InterruptedException - if the calling thread was interrupted.