mirror of
https://codeberg.org/Mercury-IM/Smack
synced 2025-12-11 23:51:09 +01: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
|
|
@ -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