mirror of
https://github.com/vanitasvitae/Smack.git
synced 2025-09-10 17:49:38 +02:00
SMACK-279: The XMPPConnection extends the new abstract Connection class
git-svn-id: http://svn.igniterealtime.org/svn/repos/smack/trunk@11613 b35dd754-fafc-0310-a699-88a17e54d16e
This commit is contained in:
parent
11a41e79ca
commit
127319a821
102 changed files with 1420 additions and 1194 deletions
|
@ -27,7 +27,7 @@ import java.util.List;
|
|||
import org.jivesoftware.smack.ConnectionCreationListener;
|
||||
import org.jivesoftware.smack.PacketListener;
|
||||
import org.jivesoftware.smack.RosterListener;
|
||||
import org.jivesoftware.smack.XMPPConnection;
|
||||
import org.jivesoftware.smack.Connection;
|
||||
import org.jivesoftware.smack.XMPPException;
|
||||
import org.jivesoftware.smack.filter.PacketFilter;
|
||||
import org.jivesoftware.smack.packet.IQ;
|
||||
|
@ -99,7 +99,7 @@ import org.jivesoftware.smackx.provider.JingleProvider;
|
|||
* try {
|
||||
* <p/>
|
||||
* // Connect to a XMPP Server
|
||||
* XMPPConnection x1 = new XMPPConnection("xmpp.com");
|
||||
* Connection x1 = new XMPPConnection("xmpp.com");
|
||||
* x1.connect();
|
||||
* x1.login("juliet", "juliet");
|
||||
* <p/>
|
||||
|
@ -142,7 +142,7 @@ import org.jivesoftware.smackx.provider.JingleProvider;
|
|||
* try {
|
||||
* <p/>
|
||||
* // Connect to a XMPP Server
|
||||
* XMPPConnection x0 = new XMPPConnection("xmpp.com");
|
||||
* Connection x0 = new XMPPConnection("xmpp.com");
|
||||
* x0.connect();
|
||||
* x0.login("romeo", "romeo");
|
||||
* <p/>
|
||||
|
@ -197,19 +197,19 @@ public class JingleManager implements JingleSessionListener {
|
|||
private List<CreatedJingleSessionListener> creationListeners = new ArrayList<CreatedJingleSessionListener>();
|
||||
|
||||
// The XMPP connection
|
||||
private XMPPConnection connection;
|
||||
private Connection connection;
|
||||
|
||||
// The Media Managers
|
||||
private List<JingleMediaManager> jingleMediaManagers;
|
||||
|
||||
/**
|
||||
* Default constructor with a defined XMPPConnection, Transport Resolver and a Media Manager
|
||||
* Default constructor with a defined Connection, Transport Resolver and a Media Manager
|
||||
* If a fully implemented JingleMediaSession is entered, JingleManager manage Jingle signalling and jmf
|
||||
*
|
||||
* @param connection XMPP Connection to be used
|
||||
* @param jingleMediaManager an implemeted JingleMediaManager to be used.
|
||||
*/
|
||||
public JingleManager(XMPPConnection connection, List<JingleMediaManager> jingleMediaManagers) {
|
||||
public JingleManager(Connection connection, List<JingleMediaManager> jingleMediaManagers) {
|
||||
this.connection = connection;
|
||||
this.jingleMediaManagers = jingleMediaManagers;
|
||||
|
||||
|
@ -249,7 +249,7 @@ public class JingleManager implements JingleSessionListener {
|
|||
/**
|
||||
* Setup the jingle system to let the remote clients know we support Jingle.
|
||||
* (This used to be a static part of construction. The problem is a remote client might
|
||||
* attempt a Jingle connection to us after we've created an XMPPConnection, but before we've
|
||||
* attempt a Jingle connection to us after we've created a Connection, but before we've
|
||||
* setup an instance of a JingleManager. We will appear to not support Jingle. With the new
|
||||
* method you just call it once and all new connections will report Jingle support.)
|
||||
*/
|
||||
|
@ -260,8 +260,8 @@ public class JingleManager implements JingleSessionListener {
|
|||
// Enable the Jingle support on every established connection
|
||||
// The ServiceDiscoveryManager class should have been already
|
||||
// initialized
|
||||
XMPPConnection.addConnectionCreationListener(new ConnectionCreationListener() {
|
||||
public void connectionCreated(XMPPConnection connection) {
|
||||
Connection.addConnectionCreationListener(new ConnectionCreationListener() {
|
||||
public void connectionCreated(Connection connection) {
|
||||
JingleManager.setServiceEnabled(connection, true);
|
||||
}
|
||||
});
|
||||
|
@ -279,7 +279,7 @@ public class JingleManager implements JingleSessionListener {
|
|||
* disabled
|
||||
* @param enabled indicates if the service will be enabled or disabled
|
||||
*/
|
||||
public synchronized static void setServiceEnabled(XMPPConnection connection, boolean enabled) {
|
||||
public synchronized static void setServiceEnabled(Connection connection, boolean enabled) {
|
||||
if (isServiceEnabled(connection) == enabled) {
|
||||
return;
|
||||
}
|
||||
|
@ -298,7 +298,7 @@ public class JingleManager implements JingleSessionListener {
|
|||
* @return a boolean indicating if the Jingle support is enabled for the
|
||||
* given connection
|
||||
*/
|
||||
public static boolean isServiceEnabled(XMPPConnection connection) {
|
||||
public static boolean isServiceEnabled(Connection connection) {
|
||||
return ServiceDiscoveryManager.getInstanceFor(connection).includesFeature(Jingle.NAMESPACE);
|
||||
}
|
||||
|
||||
|
@ -311,7 +311,7 @@ public class JingleManager implements JingleSessionListener {
|
|||
* @return a boolean indicating whether the specified user handles Jingle
|
||||
* messages
|
||||
*/
|
||||
public static boolean isServiceEnabled(XMPPConnection connection, String userID) {
|
||||
public static boolean isServiceEnabled(Connection connection, String userID) {
|
||||
try {
|
||||
DiscoverInfo result = ServiceDiscoveryManager.getInstanceFor(connection).discoverInfo(userID);
|
||||
return result.containsFeature(Jingle.NAMESPACE);
|
||||
|
|
|
@ -22,7 +22,7 @@ package org.jivesoftware.smackx.jingle;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.jivesoftware.smack.XMPPConnection;
|
||||
import org.jivesoftware.smack.Connection;
|
||||
import org.jivesoftware.smack.XMPPException;
|
||||
import org.jivesoftware.smack.packet.IQ;
|
||||
import org.jivesoftware.smackx.jingle.listeners.JingleListener;
|
||||
|
@ -45,7 +45,7 @@ public abstract class JingleNegotiator {
|
|||
|
||||
private static final SmackLogger LOGGER = SmackLogger.getLogger(JingleNegotiator.class);
|
||||
|
||||
//private XMPPConnection connection; // The connection associated
|
||||
//private Connection connection; // The connection associated
|
||||
|
||||
protected JingleSession session;
|
||||
|
||||
|
@ -65,7 +65,7 @@ public abstract class JingleNegotiator {
|
|||
}
|
||||
|
||||
/**
|
||||
* Default constructor with a XMPPConnection
|
||||
* Default constructor with a Connection
|
||||
*
|
||||
* @param connection the connection associated
|
||||
*/
|
||||
|
@ -101,7 +101,7 @@ public abstract class JingleNegotiator {
|
|||
this.state = stateIs;
|
||||
}
|
||||
|
||||
public XMPPConnection getConnection() {
|
||||
public Connection getConnection() {
|
||||
if (session != null) {
|
||||
return session.getConnection();
|
||||
} else {
|
||||
|
|
|
@ -60,7 +60,7 @@ import java.util.Random;
|
|||
|
||||
import org.jivesoftware.smack.ConnectionListener;
|
||||
import org.jivesoftware.smack.PacketListener;
|
||||
import org.jivesoftware.smack.XMPPConnection;
|
||||
import org.jivesoftware.smack.Connection;
|
||||
import org.jivesoftware.smack.XMPPException;
|
||||
import org.jivesoftware.smack.filter.PacketFilter;
|
||||
import org.jivesoftware.smack.packet.IQ;
|
||||
|
@ -124,7 +124,7 @@ public class JingleSession extends JingleNegotiator implements MediaReceivedList
|
|||
|
||||
private JingleSessionRequest sessionRequest;
|
||||
|
||||
private XMPPConnection connection;
|
||||
private Connection connection;
|
||||
|
||||
private String sessionInitPacketID;
|
||||
|
||||
|
@ -134,7 +134,7 @@ public class JingleSession extends JingleNegotiator implements MediaReceivedList
|
|||
* Full featured JingleSession constructor
|
||||
*
|
||||
* @param conn
|
||||
* XMPPConnection
|
||||
* the Connection which is used
|
||||
* @param initiator
|
||||
* the initiator JID
|
||||
* @param responder
|
||||
|
@ -144,7 +144,7 @@ public class JingleSession extends JingleNegotiator implements MediaReceivedList
|
|||
* @param jingleMediaManager
|
||||
* the jingleMediaManager
|
||||
*/
|
||||
public JingleSession(XMPPConnection conn, String initiator, String responder, String sessionid,
|
||||
public JingleSession(Connection conn, String initiator, String responder, String sessionid,
|
||||
List<JingleMediaManager> jingleMediaManagers) {
|
||||
super();
|
||||
|
||||
|
@ -170,7 +170,7 @@ public class JingleSession extends JingleNegotiator implements MediaReceivedList
|
|||
* JingleSession constructor (for an outgoing Jingle session)
|
||||
*
|
||||
* @param conn
|
||||
* XMPPConnection
|
||||
* Connection
|
||||
* @param initiator
|
||||
* the initiator JID
|
||||
* @param responder
|
||||
|
@ -178,7 +178,7 @@ public class JingleSession extends JingleNegotiator implements MediaReceivedList
|
|||
* @param jingleMediaManager
|
||||
* the jingleMediaManager
|
||||
*/
|
||||
public JingleSession(XMPPConnection conn, JingleSessionRequest request, String initiator, String responder,
|
||||
public JingleSession(Connection conn, JingleSessionRequest request, String initiator, String responder,
|
||||
List<JingleMediaManager> jingleMediaManagers) {
|
||||
this(conn, initiator, responder, generateSessionId(), jingleMediaManagers);
|
||||
sessionRequest = request;
|
||||
|
@ -193,7 +193,7 @@ public class JingleSession extends JingleNegotiator implements MediaReceivedList
|
|||
return initiator;
|
||||
}
|
||||
|
||||
public XMPPConnection getConnection() {
|
||||
public Connection getConnection() {
|
||||
return connection;
|
||||
}
|
||||
|
||||
|
@ -640,7 +640,7 @@ public class JingleSession extends JingleNegotiator implements MediaReceivedList
|
|||
* @param connection
|
||||
* The connection to clean up
|
||||
*/
|
||||
private void unregisterInstanceFor(XMPPConnection connection) {
|
||||
private void unregisterInstanceFor(Connection connection) {
|
||||
synchronized (sessions) {
|
||||
sessions.remove(connection);
|
||||
}
|
||||
|
@ -662,7 +662,7 @@ public class JingleSession extends JingleNegotiator implements MediaReceivedList
|
|||
* A XMPP connection
|
||||
* @return a Jingle session
|
||||
*/
|
||||
public static JingleSession getInstanceFor(XMPPConnection con) {
|
||||
public static JingleSession getInstanceFor(Connection con) {
|
||||
if (con == null) {
|
||||
throw new IllegalArgumentException("Connection cannot be null");
|
||||
}
|
||||
|
@ -683,7 +683,7 @@ public class JingleSession extends JingleNegotiator implements MediaReceivedList
|
|||
* @param connection
|
||||
* The connection to set up
|
||||
*/
|
||||
private void installConnectionListeners(final XMPPConnection connection) {
|
||||
private void installConnectionListeners(final Connection connection) {
|
||||
if (connection != null) {
|
||||
connectionListener = new ConnectionListener() {
|
||||
public void connectionClosed() {
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
*/
|
||||
package org.jivesoftware.smackx.jingle.mediaimpl.demo;
|
||||
|
||||
import org.jivesoftware.smack.Connection;
|
||||
import org.jivesoftware.smack.XMPPConnection;
|
||||
import org.jivesoftware.smack.XMPPException;
|
||||
import org.jivesoftware.smackx.jingle.JingleManager;
|
||||
|
@ -43,7 +44,7 @@ import java.util.List;
|
|||
public class Demo extends JFrame {
|
||||
|
||||
private JingleTransportManager transportManager = null;
|
||||
private XMPPConnection xmppConnection = null;
|
||||
private Connection xmppConnection = null;
|
||||
|
||||
private String server = null;
|
||||
private String user = null;
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
*/
|
||||
package org.jivesoftware.smackx.jingle.nat;
|
||||
|
||||
import org.jivesoftware.smack.XMPPConnection;
|
||||
import org.jivesoftware.smack.Connection;
|
||||
import org.jivesoftware.smack.XMPPException;
|
||||
import org.jivesoftware.smackx.jingle.JingleSession;
|
||||
|
||||
|
@ -40,7 +40,7 @@ import java.util.Random;
|
|||
*/
|
||||
public class BridgedResolver extends TransportResolver {
|
||||
|
||||
XMPPConnection connection;
|
||||
Connection connection;
|
||||
|
||||
Random random = new Random();
|
||||
|
||||
|
@ -48,9 +48,9 @@ public class BridgedResolver extends TransportResolver {
|
|||
|
||||
/**
|
||||
* Constructor.
|
||||
* A Bridged Resolver need a XMPPConnection to connect to a RTP Bridge.
|
||||
* A Bridged Resolver need a Connection to connect to a RTP Bridge.
|
||||
*/
|
||||
public BridgedResolver(XMPPConnection connection) {
|
||||
public BridgedResolver(Connection connection) {
|
||||
super();
|
||||
this.connection = connection;
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
*/
|
||||
package org.jivesoftware.smackx.jingle.nat;
|
||||
|
||||
import org.jivesoftware.smack.XMPPConnection;
|
||||
import org.jivesoftware.smack.Connection;
|
||||
import org.jivesoftware.smack.XMPPException;
|
||||
import org.jivesoftware.smackx.jingle.JingleSession;
|
||||
import org.jivesoftware.smackx.jingle.listeners.CreatedJingleSessionListener;
|
||||
|
@ -35,9 +35,9 @@ import org.jivesoftware.smackx.jingle.media.PayloadType;
|
|||
*/
|
||||
public class BridgedTransportManager extends JingleTransportManager implements JingleSessionListener, CreatedJingleSessionListener {
|
||||
|
||||
XMPPConnection xmppConnection;
|
||||
Connection xmppConnection;
|
||||
|
||||
public BridgedTransportManager(XMPPConnection xmppConnection) {
|
||||
public BridgedTransportManager(Connection xmppConnection) {
|
||||
super();
|
||||
this.xmppConnection = xmppConnection;
|
||||
}
|
||||
|
|
|
@ -29,7 +29,7 @@ import java.util.HashMap;
|
|||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
|
||||
import org.jivesoftware.smack.XMPPConnection;
|
||||
import org.jivesoftware.smack.Connection;
|
||||
import org.jivesoftware.smack.XMPPException;
|
||||
import org.jivesoftware.smackx.jingle.JingleSession;
|
||||
import org.jivesoftware.smackx.jingle.SmackLogger;
|
||||
|
@ -49,7 +49,7 @@ public class ICEResolver extends TransportResolver {
|
|||
|
||||
private static final SmackLogger LOGGER = SmackLogger.getLogger(ICEResolver.class);
|
||||
|
||||
XMPPConnection connection;
|
||||
Connection connection;
|
||||
Random random = new Random();
|
||||
long sid;
|
||||
String server;
|
||||
|
@ -57,7 +57,7 @@ public class ICEResolver extends TransportResolver {
|
|||
static Map<String, ICENegociator> negociatorsMap = new HashMap<String, ICENegociator>();
|
||||
//ICENegociator iceNegociator = null;
|
||||
|
||||
public ICEResolver(XMPPConnection connection, String server, int port) {
|
||||
public ICEResolver(Connection connection, String server, int port) {
|
||||
super();
|
||||
this.connection = connection;
|
||||
this.server = server;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package org.jivesoftware.smackx.jingle.nat;
|
||||
|
||||
import org.jivesoftware.smack.XMPPConnection;
|
||||
import org.jivesoftware.smack.Connection;
|
||||
import org.jivesoftware.smack.XMPPException;
|
||||
import org.jivesoftware.smackx.jingle.JingleSession;
|
||||
import org.jivesoftware.smackx.jingle.listeners.CreatedJingleSessionListener;
|
||||
|
@ -30,7 +30,7 @@ public class ICETransportManager extends JingleTransportManager implements Jingl
|
|||
|
||||
ICEResolver iceResolver = null;
|
||||
|
||||
public ICETransportManager(XMPPConnection xmppConnection, String server, int port) {
|
||||
public ICETransportManager(Connection xmppConnection, String server, int port) {
|
||||
iceResolver = new ICEResolver(xmppConnection, server, port);
|
||||
try {
|
||||
iceResolver.initializeAndWait();
|
||||
|
|
|
@ -28,7 +28,7 @@ import java.util.Iterator;
|
|||
|
||||
import org.jivesoftware.smack.PacketCollector;
|
||||
import org.jivesoftware.smack.SmackConfiguration;
|
||||
import org.jivesoftware.smack.XMPPConnection;
|
||||
import org.jivesoftware.smack.Connection;
|
||||
import org.jivesoftware.smack.XMPPException;
|
||||
import org.jivesoftware.smack.filter.PacketIDFilter;
|
||||
import org.jivesoftware.smack.packet.IQ;
|
||||
|
@ -46,7 +46,7 @@ import org.xmlpull.v1.XmlPullParser;
|
|||
* <p/>
|
||||
* High Level Usage Example:
|
||||
* <p/>
|
||||
* RTPBridge rtpBridge = RTPBridge.getRTPBridge(xmppConnection, sessionID);
|
||||
* RTPBridge rtpBridge = RTPBridge.getRTPBridge(connection, sessionID);
|
||||
*
|
||||
* @author Thiago Camargo
|
||||
*/
|
||||
|
@ -388,23 +388,23 @@ public class RTPBridge extends IQ {
|
|||
* Get a new RTPBridge Candidate from the server.
|
||||
* If a error occurs or the server don't support RTPBridge Service, null is returned.
|
||||
*
|
||||
* @param xmppConnection
|
||||
* @param connection
|
||||
* @param sessionID
|
||||
* @return
|
||||
*/
|
||||
public static RTPBridge getRTPBridge(XMPPConnection xmppConnection, String sessionID) {
|
||||
public static RTPBridge getRTPBridge(Connection connection, String sessionID) {
|
||||
|
||||
if (!xmppConnection.isConnected()) {
|
||||
if (!connection.isConnected()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
RTPBridge rtpPacket = new RTPBridge(sessionID);
|
||||
rtpPacket.setTo(RTPBridge.NAME + "." + xmppConnection.getServiceName());
|
||||
rtpPacket.setTo(RTPBridge.NAME + "." + connection.getServiceName());
|
||||
|
||||
PacketCollector collector = xmppConnection
|
||||
PacketCollector collector = connection
|
||||
.createPacketCollector(new PacketIDFilter(rtpPacket.getPacketID()));
|
||||
|
||||
xmppConnection.sendPacket(rtpPacket);
|
||||
connection.sendPacket(rtpPacket);
|
||||
|
||||
RTPBridge response = (RTPBridge) collector
|
||||
.nextResult(SmackConfiguration.getPacketReplyTimeout());
|
||||
|
@ -418,21 +418,21 @@ public class RTPBridge extends IQ {
|
|||
/**
|
||||
* Check if the server support RTPBridge Service.
|
||||
*
|
||||
* @param xmppConnection
|
||||
* @param connection
|
||||
* @return
|
||||
*/
|
||||
public static boolean serviceAvailable(XMPPConnection xmppConnection) {
|
||||
public static boolean serviceAvailable(Connection connection) {
|
||||
|
||||
if (!xmppConnection.isConnected()) {
|
||||
if (!connection.isConnected()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
LOGGER.debug("Service listing");
|
||||
|
||||
ServiceDiscoveryManager disco = ServiceDiscoveryManager
|
||||
.getInstanceFor(xmppConnection);
|
||||
.getInstanceFor(connection);
|
||||
try {
|
||||
// DiscoverItems items = disco.discoverItems(xmppConnection.getServiceName());
|
||||
// DiscoverItems items = disco.discoverItems(connection.getServiceName());
|
||||
// Iterator iter = items.getItems();
|
||||
// while (iter.hasNext()) {
|
||||
// DiscoverItems.Item item = (DiscoverItems.Item) iter.next();
|
||||
|
@ -441,7 +441,7 @@ public class RTPBridge extends IQ {
|
|||
// }
|
||||
// }
|
||||
|
||||
DiscoverInfo discoInfo = disco.discoverInfo(xmppConnection.getServiceName());
|
||||
DiscoverInfo discoInfo = disco.discoverInfo(connection.getServiceName());
|
||||
Iterator iter = discoInfo.getIdentities();
|
||||
while (iter.hasNext()) {
|
||||
DiscoverInfo.Identity identity = (DiscoverInfo.Identity) iter.next();
|
||||
|
@ -460,17 +460,17 @@ public class RTPBridge extends IQ {
|
|||
/**
|
||||
* Check if the server support RTPBridge Service.
|
||||
*
|
||||
* @param xmppConnection
|
||||
* @param connection
|
||||
* @return
|
||||
*/
|
||||
public static RTPBridge relaySession(XMPPConnection xmppConnection, String sessionID, String pass, TransportCandidate proxyCandidate, TransportCandidate localCandidate) {
|
||||
public static RTPBridge relaySession(Connection connection, String sessionID, String pass, TransportCandidate proxyCandidate, TransportCandidate localCandidate) {
|
||||
|
||||
if (!xmppConnection.isConnected()) {
|
||||
if (!connection.isConnected()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
RTPBridge rtpPacket = new RTPBridge(sessionID, RTPBridge.BridgeAction.change);
|
||||
rtpPacket.setTo(RTPBridge.NAME + "." + xmppConnection.getServiceName());
|
||||
rtpPacket.setTo(RTPBridge.NAME + "." + connection.getServiceName());
|
||||
rtpPacket.setType(Type.SET);
|
||||
|
||||
rtpPacket.setPass(pass);
|
||||
|
@ -481,10 +481,10 @@ public class RTPBridge extends IQ {
|
|||
|
||||
// LOGGER.debug("Relayed to: " + candidate.getIp() + ":" + candidate.getPort());
|
||||
|
||||
PacketCollector collector = xmppConnection
|
||||
PacketCollector collector = connection
|
||||
.createPacketCollector(new PacketIDFilter(rtpPacket.getPacketID()));
|
||||
|
||||
xmppConnection.sendPacket(rtpPacket);
|
||||
connection.sendPacket(rtpPacket);
|
||||
|
||||
RTPBridge response = (RTPBridge) collector
|
||||
.nextResult(SmackConfiguration.getPacketReplyTimeout());
|
||||
|
@ -501,7 +501,7 @@ public class RTPBridge extends IQ {
|
|||
* @param xmppConnection
|
||||
* @return public IP String or null if not found
|
||||
*/
|
||||
public static String getPublicIP(XMPPConnection xmppConnection) {
|
||||
public static String getPublicIP(Connection xmppConnection) {
|
||||
|
||||
if (!xmppConnection.isConnected()) {
|
||||
return null;
|
||||
|
|
|
@ -25,7 +25,7 @@ import java.util.List;
|
|||
|
||||
import org.jivesoftware.smack.PacketCollector;
|
||||
import org.jivesoftware.smack.SmackConfiguration;
|
||||
import org.jivesoftware.smack.XMPPConnection;
|
||||
import org.jivesoftware.smack.Connection;
|
||||
import org.jivesoftware.smack.XMPPException;
|
||||
import org.jivesoftware.smack.filter.PacketIDFilter;
|
||||
import org.jivesoftware.smack.packet.IQ;
|
||||
|
@ -42,7 +42,7 @@ import org.xmlpull.v1.XmlPullParser;
|
|||
* <p/>
|
||||
* High Level Usage Example:
|
||||
* <p/>
|
||||
* STUN stun = STUN.getSTUNServer(xmppConnection);
|
||||
* STUN stun = STUN.getSTUNServer(connection);
|
||||
*
|
||||
* @author Thiago Camargo
|
||||
*/
|
||||
|
@ -185,22 +185,22 @@ public class STUN extends IQ {
|
|||
* 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.
|
||||
*
|
||||
* @param xmppConnection
|
||||
* @param connection
|
||||
* @return
|
||||
*/
|
||||
public static STUN getSTUNServer(XMPPConnection xmppConnection) {
|
||||
public static STUN getSTUNServer(Connection connection) {
|
||||
|
||||
if (!xmppConnection.isConnected()) {
|
||||
if (!connection.isConnected()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
STUN stunPacket = new STUN();
|
||||
stunPacket.setTo(DOMAIN + "." + xmppConnection.getServiceName());
|
||||
stunPacket.setTo(DOMAIN + "." + connection.getServiceName());
|
||||
|
||||
PacketCollector collector = xmppConnection
|
||||
PacketCollector collector = connection
|
||||
.createPacketCollector(new PacketIDFilter(stunPacket.getPacketID()));
|
||||
|
||||
xmppConnection.sendPacket(stunPacket);
|
||||
connection.sendPacket(stunPacket);
|
||||
|
||||
STUN response = (STUN) collector
|
||||
.nextResult(SmackConfiguration.getPacketReplyTimeout());
|
||||
|
@ -217,18 +217,18 @@ public class STUN extends IQ {
|
|||
* @param xmppConnection
|
||||
* @return
|
||||
*/
|
||||
public static boolean serviceAvailable(XMPPConnection xmppConnection) {
|
||||
public static boolean serviceAvailable(Connection connection) {
|
||||
|
||||
if (!xmppConnection.isConnected()) {
|
||||
if (!connection.isConnected()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
LOGGER.debug("Service listing");
|
||||
|
||||
ServiceDiscoveryManager disco = ServiceDiscoveryManager
|
||||
.getInstanceFor(xmppConnection);
|
||||
.getInstanceFor(connection);
|
||||
try {
|
||||
DiscoverItems items = disco.discoverItems(xmppConnection.getServiceName());
|
||||
DiscoverItems items = disco.discoverItems(connection.getServiceName());
|
||||
|
||||
Iterator iter = items.getItems();
|
||||
while (iter.hasNext()) {
|
||||
|
|
|
@ -63,7 +63,7 @@ import java.nio.ByteBuffer;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.jivesoftware.smack.XMPPConnection;
|
||||
import org.jivesoftware.smack.Connection;
|
||||
import org.jivesoftware.smackx.jingle.JingleSession;
|
||||
import org.jivesoftware.smackx.jingle.SmackLogger;
|
||||
|
||||
|
@ -94,7 +94,7 @@ public abstract class TransportCandidate {
|
|||
|
||||
private String sessionId;
|
||||
|
||||
private XMPPConnection connection;
|
||||
private Connection connection;
|
||||
|
||||
private TransportCandidate symmetric;
|
||||
|
||||
|
@ -190,20 +190,20 @@ public abstract class TransportCandidate {
|
|||
}
|
||||
|
||||
/**
|
||||
* Get the XMPPConnection use to send or receive this candidate
|
||||
* Get the Connection use to send or receive this candidate
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public XMPPConnection getConnection() {
|
||||
public Connection getConnection() {
|
||||
return connection;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the XMPPConnection use to send or receive this candidate
|
||||
* Set the Connection use to send or receive this candidate
|
||||
*
|
||||
* @param connection
|
||||
*/
|
||||
public void setConnection(XMPPConnection connection) {
|
||||
public void setConnection(Connection connection) {
|
||||
this.connection = connection;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue