mirror of
https://github.com/vanitasvitae/Smack.git
synced 2024-09-27 10:09:32 +02:00
9d598f1398
git-svn-id: http://svn.igniterealtime.org/svn/repos/smack/trunk@7142 b35dd754-fafc-0310-a699-88a17e54d16e
67 lines
1.5 KiB
Java
67 lines
1.5 KiB
Java
package org.jivesoftware.smackx.jingle.nat;
|
|
|
|
import org.jivesoftware.smack.XMPPException;
|
|
|
|
/**
|
|
* The FixedResolver is a resolver where
|
|
* the external address and port are previously known when the object is
|
|
* initialized.
|
|
*
|
|
* @author Alvaro Saurin <alvaro.saurin@gmail.com>
|
|
*/
|
|
public class FixedResolver extends TransportResolver {
|
|
|
|
TransportCandidate fixedCandidate;
|
|
|
|
/**
|
|
* Constructor.
|
|
*/
|
|
public FixedResolver(String ip, int port) {
|
|
super();
|
|
setFixedCandidate(ip, port);
|
|
}
|
|
|
|
/**
|
|
* Create a basic resolver, where we provide the IP and port.
|
|
*
|
|
* @param ip an IP address
|
|
* @param port a port
|
|
*/
|
|
public void setFixedCandidate(String ip, int port) {
|
|
fixedCandidate = new TransportCandidate.Fixed(ip, port);
|
|
}
|
|
|
|
/**
|
|
* Resolve the IP address.
|
|
*/
|
|
public synchronized void resolve() throws XMPPException {
|
|
if (!isResolving()) {
|
|
setResolveInit();
|
|
|
|
clearCandidates();
|
|
|
|
if (fixedCandidate.getLocalIp() == null)
|
|
fixedCandidate.setLocalIp(fixedCandidate.getIp());
|
|
|
|
if (fixedCandidate != null) {
|
|
addCandidate(fixedCandidate);
|
|
}
|
|
|
|
setResolveEnd();
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Initialize the resolver.
|
|
*
|
|
* @throws XMPPException
|
|
*/
|
|
public void initialize() throws XMPPException {
|
|
setInitialized();
|
|
}
|
|
|
|
public void cancel() throws XMPPException {
|
|
// Nothing to do here
|
|
}
|
|
}
|