/* * Jitsi, the OpenSource Java VoIP and Instant Messaging client. * * Distributable under LGPL license. * See terms of license at gnu.org. */ package net.java.sip.communicator.impl.protocol.jabber; import java.lang.reflect.*; import java.net.*; import org.ice4j.*; import org.ice4j.ice.*; import org.ice4j.socket.*; /** * Represents a Candidate obtained via Jingle Nodes. * * @author Sebastien Vincent */ public class JingleNodesCandidate extends LocalCandidate { /** * The socket used to communicate with relay. */ private IceSocketWrapper socket = null; /** * The RelayedCandidateDatagramSocket of this * JingleNodesCandidate. */ private JingleNodesCandidateDatagramSocket jingleNodesCandidateDatagramSocket = null; /** * TransportAddress of the Jingle Nodes relay where we will send * our packet. */ private TransportAddress localEndPoint = null; /** * Creates a JingleNodesRelayedCandidate for the specified * transport, address, and base. * * @param transportAddress the transport address that this candidate is * encapsulating. * @param parentComponent the Component that this candidate * belongs to. * @param localEndPoint TransportAddress of the Jingle Nodes relay * where we will send our packet. */ public JingleNodesCandidate(TransportAddress transportAddress, Component parentComponent, TransportAddress localEndPoint) { super( transportAddress, parentComponent, CandidateType.RELAYED_CANDIDATE, CandidateExtendedType.JINGLE_NODE_CANDIDATE, null); setBase(this); setRelayServerAddress(localEndPoint); this.localEndPoint = localEndPoint; } /** * Gets the JingleNodesCandidateDatagramSocket of this * JingleNodesCandidate. *

* Note: The method is part of the internal API of * RelayedCandidate and TurnCandidateHarvest and is not * intended for public use. *

* * @return the RelayedCandidateDatagramSocket of this * RelayedCandidate */ public synchronized JingleNodesCandidateDatagramSocket getRelayedCandidateDatagramSocket() { if (jingleNodesCandidateDatagramSocket == null) { try { jingleNodesCandidateDatagramSocket = new JingleNodesCandidateDatagramSocket( this, localEndPoint); } catch (SocketException sex) { throw new UndeclaredThrowableException(sex); } } return jingleNodesCandidateDatagramSocket; } /** * Gets the DatagramSocket associated with this Candidate. * * @return the DatagramSocket associated with this * Candidate */ @Override public IceSocketWrapper getIceSocketWrapper() { if (socket == null) { try { socket = new IceUdpSocketWrapper(new MultiplexingDatagramSocket( getRelayedCandidateDatagramSocket())); } catch (SocketException sex) { throw new UndeclaredThrowableException(sex); } } return socket; } }