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:
org.jivesoftware.smack.packet.Element
,org.jivesoftware.smack.packet.FullyQualifiedElement
,org.jivesoftware.smack.packet.IqView
,org.jivesoftware.smack.packet.NamedElement
,org.jivesoftware.smack.packet.StanzaView
,org.jivesoftware.smack.packet.TopLevelStreamElement
,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
STUN.Provider
IQProvider for RTP Bridge packets.static class
STUN.StunServerAddress
Provides easy abstract to store STUN Server Addresses and Ports.
-
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.
-
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(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.IQ
createErrorResponse, createErrorResponse, createErrorResponse, createResultIQ, getChildElementName, getChildElementNamespace, getChildElementQName, getChildElementXML, getElementName, getType, isRequestIQ, isResponseIQ, 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
-
-
-
-
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
-
-
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(org.jivesoftware.smack.XMPPConnection connection) throws org.jivesoftware.smack.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:
org.jivesoftware.smack.SmackException.NotConnectedException
- if the XMPP connection is not connected.java.lang.InterruptedException
- if the calling thread was interrupted.
-
serviceAvailable
public static boolean serviceAvailable(org.jivesoftware.smack.XMPPConnection connection) throws org.jivesoftware.smack.XMPPException, org.jivesoftware.smack.SmackException, java.lang.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.java.lang.InterruptedException
- if the calling thread was interrupted.
-
-