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.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.SimpleIQSTUN 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 classSTUN.ProviderIQProvider for RTP Bridge packets.static classSTUN.StunServerAddressProvides easy abstract to store STUN Server Addresses and Ports.
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringDOMAINElement name of the stanza extension.static java.lang.StringELEMENT_NAMEElement name of the stanza extension.static java.lang.StringNAMESPACENamespace 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.StringgetPublicIp()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 STUNgetSTUNServer(org.jivesoftware.smack.XMPPConnection connection)Get a new STUN Server Address and port from the server.static booleanserviceAvailable(org.jivesoftware.smack.XMPPConnection connection)Check if the server support STUN Service.-
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
-
-
-
-
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, 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.java.lang.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, java.lang.InterruptedExceptionCheck 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.
-
-