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
,IqView
,NamedElement
,StanzaView
,TopLevelStreamElement
,XmlElement
,XmlLangElement
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
Modifier and TypeClassDescriptionstatic 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
IQ.IQChildElementXmlStringBuilder, IQ.ResponseType, IQ.Type
-
Field Summary
Modifier and TypeFieldDescriptionstatic 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
-
Method Summary
Modifier and TypeMethodDescriptionGet Public Ip returned from the XMPP server.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, 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.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
-
DOMAIN
Element name of the stanza extension.- See Also:
-
ELEMENT_NAME
Element name of the stanza extension.- See Also:
-
NAMESPACE
Namespace of the stanza extension.- See Also:
-
-
Constructor Details
-
STUN
public STUN()Creates a STUN IQ.
-
-
Method Details
-
getServers
Get a list of STUN Servers recommended by the Server.- Returns:
- the list of STUN servers
-
getPublicIp
Get Public Ip returned from the XMPP server.- Returns:
- the public IP
-
getSTUNServer
public static STUN getSTUNServer(XMPPConnection connection) throws SmackException.NotConnectedException, InterruptedException, SmackException.NoResponseException, 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:
SmackException.NotConnectedException
- if the XMPP connection is not connected.InterruptedException
- if the calling thread was interrupted.XMPPException.XMPPErrorException
- if there was an XMPP error returned.SmackException.NoResponseException
- if there was no response from the remote entity.
-
serviceAvailable
public static boolean serviceAvailable(XMPPConnection connection) throws XMPPException, SmackException, 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.InterruptedException
- if the calling thread was interrupted.
-