Class STUN
- 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:
Element
,FullyQualifiedElement
,IqView
,NamedElement
,StanzaView
,TopLevelStreamElement
,XmlLangElement
public class STUN extends 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
STUN.Provider
IQProvider for RTP Bridge packets.static class
STUN.StunServerAddress
Provides easy abstract to store STUN Server Addresses and Ports.-
Nested classes/interfaces inherited from class org.jivesoftware.smack.packet.IQ
IQ.IQChildElementXmlStringBuilder, IQ.ResponseType, IQ.Type
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
DOMAIN
Element name of the stanza extension.static java.lang.String
ELEMENT_NAME
Element name of the stanza extension.static java.lang.String
NAMESPACE
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 STUN()
Creates a STUN IQ.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.String
getPublicIp()
Get Public Ip returned from the XMPP server.java.util.List<STUN.StunServerAddress>
getServers()
Get a list of STUN Servers recommended by the Server.static STUN
getSTUNServer(XMPPConnection connection)
Get a new STUN Server Address and port from the server.static boolean
serviceAvailable(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, 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, getExtension, getExtensionElement, getExtensions, getExtensions, getExtensions, getExtensions, getExtensionsMap, getFrom, getLanguage, getNamespace, getStanzaId, getTo, hasExtension, hasExtension, hasStanzaIdSet, logCommonAttributes, overrideExtension, removeExtension, removeExtension, setError, setError, setFrom, setLanguage, setNewStanzaId, setStanzaId, 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.FullyQualifiedElement
getQName
-
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
-
-
-
-
Field Detail
-
DOMAIN
public static final java.lang.String DOMAIN
Element name of the stanza extension.- See Also:
- Constant Field Values
-
ELEMENT_NAME
public static final java.lang.String ELEMENT_NAME
Element name of the stanza extension.- See Also:
- Constant Field Values
-
NAMESPACE
public static final java.lang.String NAMESPACE
Namespace of the stanza extension.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
STUN
public STUN()
Creates a STUN IQ.
-
-
Method Detail
-
getServers
public java.util.List<STUN.StunServerAddress> getServers()
Get a list of STUN Servers recommended by the Server.- Returns:
- the list of STUN servers
-
getPublicIp
public java.lang.String getPublicIp()
Get Public Ip returned from the XMPP server.- Returns:
- the public IP
-
getSTUNServer
public static STUN getSTUNServer(XMPPConnection connection) throws SmackException.NotConnectedException, java.lang.InterruptedException
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:
SmackException.NotConnectedException
- if the XMPP connection is not connected.java.lang.InterruptedException
- if the calling thread was interrupted.
-
serviceAvailable
public static boolean serviceAvailable(XMPPConnection connection) throws XMPPException, SmackException, java.lang.InterruptedException
Check if the server support STUN Service.- Parameters:
connection
- the connection- Returns:
- true if the server support STUN
- Throws:
SmackException
- if Smack detected an exceptional situation.XMPPException
- if an XMPP protocol error was received.java.lang.InterruptedException
- if the calling thread was interrupted.
-
-