mirror of
https://github.com/vanitasvitae/Smack.git
synced 2024-09-19 06:09:32 +02:00
Renamed Connection to XMPPConnection
This commit is contained in:
parent
f3e007bad5
commit
489816c61f
|
@ -14,7 +14,7 @@ Key Advantages :
|
|||
- Extremely simple to use, yet powerful API. Sending a text message to a user can be accomplished in only a few lines of code:
|
||||
|
||||
```java
|
||||
Connection connection = new XMPPConnection("jabber.org");
|
||||
XMPPConnection connection = new TCPConnection("jabber.org");
|
||||
connection.connect();
|
||||
connection.login("mtucker", "password");
|
||||
Chat chat = connection.getChatManager()
|
||||
|
|
|
@ -25,7 +25,7 @@ import java.util.concurrent.ExecutorService;
|
|||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.ThreadFactory;
|
||||
|
||||
import org.jivesoftware.smack.Connection;
|
||||
import org.jivesoftware.smack.XMPPConnection;
|
||||
import org.jivesoftware.smack.ConnectionCreationListener;
|
||||
import org.jivesoftware.smack.ConnectionListener;
|
||||
import org.jivesoftware.smack.PacketCollector;
|
||||
|
@ -51,10 +51,10 @@ import org.igniterealtime.jbosh.ComposableBody;
|
|||
* Creates a connection to a XMPP server via HTTP binding.
|
||||
* This is specified in the XEP-0206: XMPP Over BOSH.
|
||||
*
|
||||
* @see Connection
|
||||
* @see XMPPConnection
|
||||
* @author Guenther Niess
|
||||
*/
|
||||
public class BOSHConnection extends Connection {
|
||||
public class BOSHConnection extends XMPPConnection {
|
||||
|
||||
/**
|
||||
* The XMPP Over Bosh namespace.
|
||||
|
|
|
@ -167,7 +167,7 @@ public class MessageTest extends SmackTestCase {
|
|||
// Send the first message
|
||||
getConnection(0).sendPacket(msg);
|
||||
// Check that the connection that sent the message is still connected
|
||||
assertTrue("Connection was closed", getConnection(0).isConnected());
|
||||
assertTrue("XMPPConnection was closed", getConnection(0).isConnected());
|
||||
// Check that the message was received
|
||||
Message rcv = (Message) collector.nextResult(1000);
|
||||
assertNotNull("No Message was received", rcv);
|
||||
|
@ -175,7 +175,7 @@ public class MessageTest extends SmackTestCase {
|
|||
// Send the second message
|
||||
getConnection(0).sendPacket(msg);
|
||||
// Check that the connection that sent the message is still connected
|
||||
assertTrue("Connection was closed", getConnection(0).isConnected());
|
||||
assertTrue("XMPPConnection was closed", getConnection(0).isConnected());
|
||||
// Check that the second message was received
|
||||
rcv = (Message) collector.nextResult(1000);
|
||||
assertNotNull("No Message was received", rcv);
|
||||
|
|
|
@ -35,8 +35,8 @@ public class PresenceTest extends SmackTestCase {
|
|||
}
|
||||
|
||||
/**
|
||||
* Connection(0) will send messages to the bareJID of Connection(1) where the user of
|
||||
* Connection(1) has logged from two different places with different presence priorities.
|
||||
* XMPPConnection(0) will send messages to the bareJID of XMPPConnection(1) where the user of
|
||||
* XMPPConnection(1) has logged from two different places with different presence priorities.
|
||||
*/
|
||||
public void testMessageToHighestPriority() {
|
||||
TCPConnection conn = null;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package org.jivesoftware.smack.util;
|
||||
|
||||
import org.jivesoftware.smack.Connection;
|
||||
import org.jivesoftware.smack.XMPPConnection;
|
||||
import org.jivesoftware.smack.Roster;
|
||||
import org.jivesoftware.smack.XMPPException;
|
||||
|
||||
|
@ -8,7 +8,7 @@ public class ConnectionUtils {
|
|||
|
||||
private ConnectionUtils() {}
|
||||
|
||||
public static void becomeFriends(Connection con0, Connection con1) throws XMPPException {
|
||||
public static void becomeFriends(XMPPConnection con0, XMPPConnection con1) throws XMPPException {
|
||||
Roster r0 = con0.getRoster();
|
||||
Roster r1 = con1.getRoster();
|
||||
r0.setSubscriptionMode(Roster.SubscriptionMode.accept_all);
|
||||
|
@ -17,9 +17,9 @@ public class ConnectionUtils {
|
|||
r1.createEntry(con0.getUser(), "u1", null);
|
||||
}
|
||||
|
||||
public static void letsAllBeFriends(Connection[] connections) throws XMPPException {
|
||||
for (Connection c1 : connections) {
|
||||
for (Connection c2 : connections) {
|
||||
public static void letsAllBeFriends(XMPPConnection[] connections) throws XMPPException {
|
||||
for (XMPPConnection c1 : connections) {
|
||||
for (XMPPConnection c2 : connections) {
|
||||
if (c1 == c2)
|
||||
continue;
|
||||
becomeFriends(c1, c2);
|
||||
|
|
|
@ -31,13 +31,13 @@ import org.jivesoftware.smack.util.StringUtils;
|
|||
/**
|
||||
* Allows creation and management of accounts on an XMPP server.
|
||||
*
|
||||
* @see Connection#getAccountManager()
|
||||
* @see XMPPConnection#getAccountManager()
|
||||
* @author Matt Tucker
|
||||
*/
|
||||
public class AccountManager {
|
||||
private static final Logger LOGGER = Logger.getLogger(AccountManager.class.getName());
|
||||
|
||||
private Connection connection;
|
||||
private XMPPConnection connection;
|
||||
private Registration info = null;
|
||||
|
||||
/**
|
||||
|
@ -53,7 +53,7 @@ public class AccountManager {
|
|||
*
|
||||
* @param connection a connection to a XMPP server.
|
||||
*/
|
||||
public AccountManager(Connection connection) {
|
||||
public AccountManager(XMPPConnection connection) {
|
||||
this.connection = connection;
|
||||
}
|
||||
|
||||
|
|
|
@ -151,7 +151,7 @@ public class Chat {
|
|||
/**
|
||||
* Delivers a message directly to this chat, which will add the message
|
||||
* to the collector and deliver it to all listeners registered with the
|
||||
* Chat. This is used by the Connection class to deliver messages
|
||||
* Chat. This is used by the XMPPConnection class to deliver messages
|
||||
* without a thread ID.
|
||||
*
|
||||
* @param message the message.
|
||||
|
|
|
@ -108,9 +108,9 @@ public class ChatManager {
|
|||
private Map<PacketInterceptor, PacketFilter> interceptors
|
||||
= new WeakHashMap<PacketInterceptor, PacketFilter>();
|
||||
|
||||
private Connection connection;
|
||||
private XMPPConnection connection;
|
||||
|
||||
ChatManager(Connection connection) {
|
||||
ChatManager(XMPPConnection connection) {
|
||||
this.connection = connection;
|
||||
|
||||
PacketFilter filter = new PacketFilter() {
|
||||
|
|
|
@ -63,7 +63,7 @@ public class ConnectionConfiguration implements Cloneable {
|
|||
*/
|
||||
private CallbackHandler callbackHandler;
|
||||
|
||||
private boolean debuggerEnabled = Connection.DEBUG_ENABLED;
|
||||
private boolean debuggerEnabled = XMPPConnection.DEBUG_ENABLED;
|
||||
|
||||
// Flag that indicates if a reconnection should be attempted when abruptly disconnected
|
||||
private boolean reconnectionAllowed = true;
|
||||
|
@ -368,7 +368,7 @@ public class ConnectionConfiguration implements Cloneable {
|
|||
|
||||
/**
|
||||
* Returns true if the new connection about to be establish is going to be debugged. By
|
||||
* default the value of {@link Connection#DEBUG_ENABLED} is used.
|
||||
* default the value of {@link XMPPConnection#DEBUG_ENABLED} is used.
|
||||
*
|
||||
* @return true if the new connection about to be establish is going to be debugged.
|
||||
*/
|
||||
|
@ -378,7 +378,7 @@ public class ConnectionConfiguration implements Cloneable {
|
|||
|
||||
/**
|
||||
* Sets if the new connection about to be establish is going to be debugged. By
|
||||
* default the value of {@link Connection#DEBUG_ENABLED} is used.
|
||||
* default the value of {@link XMPPConnection#DEBUG_ENABLED} is used.
|
||||
*
|
||||
* @param debuggerEnabled if the new connection about to be establish is going to be debugged.
|
||||
*/
|
||||
|
|
|
@ -18,9 +18,9 @@
|
|||
package org.jivesoftware.smack;
|
||||
|
||||
/**
|
||||
* Implementors of this interface will be notified when a new {@link Connection}
|
||||
* Implementors of this interface will be notified when a new {@link XMPPConnection}
|
||||
* has been created. The newly created connection will not be actually connected to
|
||||
* the server. Use {@link Connection#addConnectionCreationListener(ConnectionCreationListener)}
|
||||
* the server. Use {@link XMPPConnection#addConnectionCreationListener(ConnectionCreationListener)}
|
||||
* to add new listeners.
|
||||
*
|
||||
* @author Gaston Dombiak
|
||||
|
@ -33,6 +33,6 @@ public interface ConnectionCreationListener {
|
|||
*
|
||||
* @param connection the newly created connection.
|
||||
*/
|
||||
public void connectionCreated(Connection connection);
|
||||
public void connectionCreated(XMPPConnection connection);
|
||||
|
||||
}
|
||||
|
|
|
@ -19,10 +19,10 @@ package org.jivesoftware.smack;
|
|||
|
||||
/**
|
||||
* Interface that allows for implementing classes to listen for connection closing
|
||||
* and reconnection events. Listeners are registered with Connection objects.
|
||||
* and reconnection events. Listeners are registered with XMPPConnection objects.
|
||||
*
|
||||
* @see Connection#addConnectionListener
|
||||
* @see Connection#removeConnectionListener
|
||||
* @see XMPPConnection#addConnectionListener
|
||||
* @see XMPPConnection#removeConnectionListener
|
||||
*
|
||||
* @author Matt Tucker
|
||||
*/
|
||||
|
|
|
@ -20,13 +20,13 @@ import java.lang.ref.WeakReference;
|
|||
|
||||
public abstract class Manager {
|
||||
|
||||
final WeakReference<Connection> weakConnection;
|
||||
final WeakReference<XMPPConnection> weakConnection;
|
||||
|
||||
public Manager(Connection connection) {
|
||||
weakConnection = new WeakReference<Connection>(connection);
|
||||
public Manager(XMPPConnection connection) {
|
||||
weakConnection = new WeakReference<XMPPConnection>(connection);
|
||||
}
|
||||
|
||||
protected final Connection connection() {
|
||||
protected final XMPPConnection connection() {
|
||||
return weakConnection.get();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -35,14 +35,14 @@ import org.jivesoftware.smack.packet.XMPPError;
|
|||
* older packets are automatically dropped. The default number is retrieved by
|
||||
* {@link SmackConfiguration#getPacketCollectorSize()}.
|
||||
*
|
||||
* @see Connection#createPacketCollector(PacketFilter)
|
||||
* @see XMPPConnection#createPacketCollector(PacketFilter)
|
||||
* @author Matt Tucker
|
||||
*/
|
||||
public class PacketCollector {
|
||||
|
||||
private PacketFilter packetFilter;
|
||||
private ArrayBlockingQueue<Packet> resultQueue;
|
||||
private Connection connection;
|
||||
private XMPPConnection connection;
|
||||
private boolean cancelled = false;
|
||||
|
||||
/**
|
||||
|
@ -52,7 +52,7 @@ public class PacketCollector {
|
|||
* @param connection the connection the collector is tied to.
|
||||
* @param packetFilter determines which packets will be returned by this collector.
|
||||
*/
|
||||
protected PacketCollector(Connection connection, PacketFilter packetFilter) {
|
||||
protected PacketCollector(XMPPConnection connection, PacketFilter packetFilter) {
|
||||
this(connection, packetFilter, SmackConfiguration.getPacketCollectorSize());
|
||||
}
|
||||
|
||||
|
@ -64,7 +64,7 @@ public class PacketCollector {
|
|||
* @param packetFilter determines which packets will be returned by this collector.
|
||||
* @param maxSize the maximum number of packets that will be stored in the collector.
|
||||
*/
|
||||
protected PacketCollector(Connection connection, PacketFilter packetFilter, int maxSize) {
|
||||
protected PacketCollector(XMPPConnection connection, PacketFilter packetFilter, int maxSize) {
|
||||
this.connection = connection;
|
||||
this.packetFilter = packetFilter;
|
||||
this.resultQueue = new ArrayBlockingQueue<Packet>(maxSize);
|
||||
|
|
|
@ -21,14 +21,14 @@ import org.jivesoftware.smack.packet.Packet;
|
|||
|
||||
/**
|
||||
* Provides a mechanism to intercept and modify packets that are going to be
|
||||
* sent to the server. PacketInterceptors are added to the {@link Connection}
|
||||
* sent to the server. PacketInterceptors are added to the {@link XMPPConnection}
|
||||
* together with a {@link org.jivesoftware.smack.filter.PacketFilter} so that only
|
||||
* certain packets are intercepted and processed by the interceptor.<p>
|
||||
*
|
||||
* This allows event-style programming -- every time a new packet is found,
|
||||
* the {@link #interceptPacket(Packet)} method will be called.
|
||||
*
|
||||
* @see Connection#addPacketInterceptor(PacketInterceptor, org.jivesoftware.smack.filter.PacketFilter)
|
||||
* @see XMPPConnection#addPacketInterceptor(PacketInterceptor, org.jivesoftware.smack.filter.PacketFilter)
|
||||
* @author Gaston Dombiak
|
||||
*/
|
||||
public interface PacketInterceptor {
|
||||
|
|
|
@ -26,7 +26,7 @@ import org.jivesoftware.smack.packet.Packet;
|
|||
* opposite approach to the functionality provided by a {@link PacketCollector}
|
||||
* which lets you block while waiting for results.
|
||||
*
|
||||
* @see Connection#addPacketListener(PacketListener, org.jivesoftware.smack.filter.PacketFilter)
|
||||
* @see XMPPConnection#addPacketListener(PacketListener, org.jivesoftware.smack.filter.PacketFilter)
|
||||
* @author Matt Tucker
|
||||
*/
|
||||
public interface PacketListener {
|
||||
|
|
|
@ -37,7 +37,7 @@ public class ReconnectionManager implements ConnectionListener {
|
|||
private static final Logger LOGGER = Logger.getLogger(ReconnectionManager.class.getName());
|
||||
|
||||
// Holds the connection to the server
|
||||
private Connection connection;
|
||||
private XMPPConnection connection;
|
||||
private Thread reconnectionThread;
|
||||
private int randomBase = new Random().nextInt(11) + 5; // between 5 and 15 seconds
|
||||
|
||||
|
@ -48,14 +48,14 @@ public class ReconnectionManager implements ConnectionListener {
|
|||
// Create a new PrivacyListManager on every established connection. In the init()
|
||||
// method of PrivacyListManager, we'll add a listener that will delete the
|
||||
// instance when the connection is closed.
|
||||
Connection.addConnectionCreationListener(new ConnectionCreationListener() {
|
||||
public void connectionCreated(Connection connection) {
|
||||
XMPPConnection.addConnectionCreationListener(new ConnectionCreationListener() {
|
||||
public void connectionCreated(XMPPConnection connection) {
|
||||
connection.addConnectionListener(new ReconnectionManager(connection));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private ReconnectionManager(Connection connection) {
|
||||
private ReconnectionManager(XMPPConnection connection) {
|
||||
this.connection = connection;
|
||||
}
|
||||
|
||||
|
@ -117,7 +117,7 @@ public class ReconnectionManager implements ConnectionListener {
|
|||
*/
|
||||
public void run() {
|
||||
// The process will try to reconnect until the connection is established or
|
||||
// the user cancel the reconnection process {@link Connection#disconnect()}
|
||||
// the user cancel the reconnection process {@link XMPPConnection#disconnect()}
|
||||
while (ReconnectionManager.this.isReconnectionAllowed()) {
|
||||
// Find how much time we should wait until the next reconnection
|
||||
int remainingSeconds = timeDelay();
|
||||
|
@ -173,7 +173,7 @@ public class ReconnectionManager implements ConnectionListener {
|
|||
}
|
||||
|
||||
/**
|
||||
* Fires listeners when The Connection will retry a reconnection. Expressed in seconds.
|
||||
* Fires listeners when The XMPPConnection will retry a reconnection. Expressed in seconds.
|
||||
*
|
||||
* @param seconds the number of seconds that a reconnection will be attempted in.
|
||||
*/
|
||||
|
|
|
@ -52,7 +52,7 @@ import org.jivesoftware.smack.util.StringUtils;
|
|||
* </ul>
|
||||
*
|
||||
* @author Matt Tucker
|
||||
* @see Connection#getRoster()
|
||||
* @see XMPPConnection#getRoster()
|
||||
*/
|
||||
public class Roster {
|
||||
|
||||
|
@ -62,7 +62,7 @@ public class Roster {
|
|||
*/
|
||||
private static SubscriptionMode defaultSubscriptionMode = SubscriptionMode.accept_all;
|
||||
|
||||
private final Connection connection;
|
||||
private final XMPPConnection connection;
|
||||
private final RosterStore rosterStore;
|
||||
private final Map<String, RosterGroup> groups;
|
||||
private final Map<String,RosterEntry> entries;
|
||||
|
@ -105,7 +105,7 @@ public class Roster {
|
|||
*
|
||||
* @param connection an XMPP connection.
|
||||
*/
|
||||
Roster(final Connection connection) {
|
||||
Roster(final XMPPConnection connection) {
|
||||
this.connection = connection;
|
||||
rosterStore = connection.getConfiguration().getRosterStore();
|
||||
groups = new ConcurrentHashMap<String, RosterGroup>();
|
||||
|
@ -138,9 +138,9 @@ public class Roster {
|
|||
|
||||
// if not connected add listener after successful login
|
||||
if(!this.connection.isConnected()) {
|
||||
Connection.addConnectionCreationListener(new ConnectionCreationListener() {
|
||||
XMPPConnection.addConnectionCreationListener(new ConnectionCreationListener() {
|
||||
|
||||
public void connectionCreated(Connection connection) {
|
||||
public void connectionCreated(XMPPConnection connection) {
|
||||
if(connection.equals(Roster.this.connection)) {
|
||||
Roster.this.connection.addConnectionListener(connectionListener);
|
||||
}
|
||||
|
|
|
@ -35,7 +35,7 @@ public class RosterEntry {
|
|||
private RosterPacket.ItemType type;
|
||||
private RosterPacket.ItemStatus status;
|
||||
final private Roster roster;
|
||||
final private Connection connection;
|
||||
final private XMPPConnection connection;
|
||||
|
||||
/**
|
||||
* Creates a new roster entry.
|
||||
|
@ -47,7 +47,7 @@ public class RosterEntry {
|
|||
* @param connection a connection to the XMPP server.
|
||||
*/
|
||||
RosterEntry(String user, String name, RosterPacket.ItemType type,
|
||||
RosterPacket.ItemStatus status, Roster roster, Connection connection) {
|
||||
RosterPacket.ItemStatus status, Roster roster, XMPPConnection connection) {
|
||||
this.user = user;
|
||||
this.name = name;
|
||||
this.type = type;
|
||||
|
|
|
@ -36,7 +36,7 @@ import org.jivesoftware.smack.util.StringUtils;
|
|||
public class RosterGroup {
|
||||
|
||||
private String name;
|
||||
private Connection connection;
|
||||
private XMPPConnection connection;
|
||||
private final Set<RosterEntry> entries;
|
||||
|
||||
/**
|
||||
|
@ -45,7 +45,7 @@ public class RosterGroup {
|
|||
* @param name the name of the group.
|
||||
* @param connection the connection the group belongs to.
|
||||
*/
|
||||
RosterGroup(String name, Connection connection) {
|
||||
RosterGroup(String name, XMPPConnection connection) {
|
||||
this.name = name;
|
||||
this.connection = connection;
|
||||
entries = new LinkedHashSet<RosterEntry>();
|
||||
|
|
|
@ -61,7 +61,7 @@ public class SASLAuthentication {
|
|||
private static Map<String, Class<? extends SASLMechanism>> implementedMechanisms = new HashMap<String, Class<? extends SASLMechanism>>();
|
||||
private static List<String> mechanismsPreferences = new ArrayList<String>();
|
||||
|
||||
private Connection connection;
|
||||
private XMPPConnection connection;
|
||||
private Collection<String> serverMechanisms = new ArrayList<String>();
|
||||
private SASLMechanism currentMechanism = null;
|
||||
/**
|
||||
|
@ -170,7 +170,7 @@ public class SASLAuthentication {
|
|||
return answer;
|
||||
}
|
||||
|
||||
SASLAuthentication(Connection connection) {
|
||||
SASLAuthentication(XMPPConnection connection) {
|
||||
super();
|
||||
this.connection = connection;
|
||||
this.init();
|
||||
|
|
|
@ -14,7 +14,6 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jivesoftware.smack;
|
||||
|
||||
import java.io.Reader;
|
||||
|
@ -47,7 +46,7 @@ import org.jivesoftware.smack.packet.Packet;
|
|||
import org.jivesoftware.smack.packet.Presence;
|
||||
|
||||
/**
|
||||
* The abstract Connection class provides an interface for connections to a
|
||||
* The abstract XMPPConnection class provides an interface for connections to a
|
||||
* XMPP server and implements shared methods which are used by the
|
||||
* different types of connections (e.g. TCPConnection or BoshConnection).
|
||||
*
|
||||
|
@ -55,7 +54,7 @@ import org.jivesoftware.smack.packet.Presence;
|
|||
* look like the following:
|
||||
* <pre>
|
||||
* // Create a connection to the igniterealtime.org XMPP server.
|
||||
* Connection con = new TCPConnection("igniterealtime.org");
|
||||
* XMPPConnection con = new TCPConnection("igniterealtime.org");
|
||||
* // Connect to the server
|
||||
* con.connect();
|
||||
* // Most servers require you to login before performing other tasks.
|
||||
|
@ -77,16 +76,15 @@ import org.jivesoftware.smack.packet.Presence;
|
|||
* may be connected, disconnected and then connected again. Listeners of the Connection
|
||||
* will be retained accross connections.<p>
|
||||
* <p/>
|
||||
* If a connected Connection gets disconnected abruptly then it will try to reconnect
|
||||
* If a connected XMPPConnection gets disconnected abruptly then it will try to reconnect
|
||||
* again. To stop the reconnection process, use {@link #disconnect()}. Once stopped
|
||||
* you can use {@link #connect()} to manually connect to the server.
|
||||
*
|
||||
* @see TCPConnection
|
||||
* @author Matt Tucker
|
||||
* @author Guenther Niess
|
||||
*/
|
||||
public abstract class Connection {
|
||||
private static final Logger LOGGER = Logger.getLogger(Connection.class.getName());
|
||||
public abstract class XMPPConnection {
|
||||
private static final Logger LOGGER = Logger.getLogger(XMPPConnection.class.getName());
|
||||
|
||||
/**
|
||||
* Counter to uniquely identify connections that are created.
|
||||
|
@ -230,11 +228,11 @@ public abstract class Connection {
|
|||
private final ScheduledExecutorService executorService = new ScheduledThreadPoolExecutor(2);
|
||||
|
||||
/**
|
||||
* Create a new Connection to a XMPP server.
|
||||
* Create a new XMPPConnection to a XMPP server.
|
||||
*
|
||||
* @param configuration The configuration which is used to establish the connection.
|
||||
*/
|
||||
protected Connection(ConnectionConfiguration configuration) {
|
||||
protected XMPPConnection(ConnectionConfiguration configuration) {
|
||||
config = configuration;
|
||||
}
|
||||
|
||||
|
@ -482,7 +480,7 @@ public abstract class Connection {
|
|||
|
||||
/**
|
||||
* Closes the connection by setting presence to unavailable then closing the connection to
|
||||
* the XMPP server. The Connection can still be used for connecting to the server
|
||||
* the XMPP server. The XMPPConnection can still be used for connecting to the server
|
||||
* again.<p>
|
||||
* <p/>
|
||||
* This method cleans up all resources used by the connection. Therefore, the roster,
|
||||
|
@ -497,7 +495,7 @@ public abstract class Connection {
|
|||
|
||||
/**
|
||||
* Closes the connection. A custom unavailable presence is sent to the server, followed
|
||||
* by closing the stream. The Connection can still be used for connecting to the server
|
||||
* by closing the stream. The XMPPConnection can still be used for connecting to the server
|
||||
* again. A custom unavilable presence is useful for communicating offline presence
|
||||
* information such as "On vacation". Typically, just the status text of the presence
|
||||
* packet is set with online information, but most XMPP servers will deliver the full
|
||||
|
@ -822,7 +820,7 @@ public abstract class Connection {
|
|||
// option
|
||||
try {
|
||||
Constructor<?> constructor = debuggerClass
|
||||
.getConstructor(Connection.class, Writer.class, Reader.class);
|
||||
.getConstructor(XMPPConnection.class, Writer.class, Reader.class);
|
||||
debugger = (SmackDebugger) constructor.newInstance(this, writer, reader);
|
||||
reader = debugger.getReader();
|
||||
writer = debugger.getWriter();
|
||||
|
@ -842,7 +840,7 @@ public abstract class Connection {
|
|||
/**
|
||||
* Set the servers Entity Caps node
|
||||
*
|
||||
* Connection holds this information in order to avoid a dependency to
|
||||
* XMPPConnection holds this information in order to avoid a dependency to
|
||||
* smackx where EntityCapsManager lives from smack.
|
||||
*
|
||||
* @param node
|
||||
|
@ -854,7 +852,7 @@ public abstract class Connection {
|
|||
/**
|
||||
* Retrieve the servers Entity Caps node
|
||||
*
|
||||
* Connection holds this information in order to avoid a dependency to
|
||||
* XMPPConnection holds this information in order to avoid a dependency to
|
||||
* smackx where EntityCapsManager lives from smack.
|
||||
*
|
||||
* @return
|
|
@ -18,7 +18,7 @@ package org.jivesoftware.smack.debugger;
|
|||
|
||||
import org.jivesoftware.smack.ConnectionListener;
|
||||
import org.jivesoftware.smack.PacketListener;
|
||||
import org.jivesoftware.smack.Connection;
|
||||
import org.jivesoftware.smack.XMPPConnection;
|
||||
import org.jivesoftware.smack.packet.Packet;
|
||||
import org.jivesoftware.smack.util.*;
|
||||
|
||||
|
@ -43,7 +43,7 @@ public class ConsoleDebugger implements SmackDebugger {
|
|||
public static boolean printInterpreted = false;
|
||||
private SimpleDateFormat dateFormatter = new SimpleDateFormat("hh:mm:ss aaa");
|
||||
|
||||
private Connection connection = null;
|
||||
private XMPPConnection connection = null;
|
||||
|
||||
private PacketListener listener = null;
|
||||
private ConnectionListener connListener = null;
|
||||
|
@ -53,7 +53,7 @@ public class ConsoleDebugger implements SmackDebugger {
|
|||
private ReaderListener readerListener;
|
||||
private WriterListener writerListener;
|
||||
|
||||
public ConsoleDebugger(Connection connection, Writer writer, Reader reader) {
|
||||
public ConsoleDebugger(XMPPConnection connection, Writer writer, Reader reader) {
|
||||
this.connection = connection;
|
||||
this.writer = writer;
|
||||
this.reader = reader;
|
||||
|
@ -111,7 +111,7 @@ public class ConsoleDebugger implements SmackDebugger {
|
|||
connListener = new ConnectionListener() {
|
||||
public void connectionClosed() {
|
||||
System.out.println(
|
||||
dateFormatter.format(new Date()) + " Connection closed (" +
|
||||
dateFormatter.format(new Date()) + " XMPPConnection closed (" +
|
||||
connection.hashCode() +
|
||||
")");
|
||||
}
|
||||
|
@ -119,7 +119,7 @@ public class ConsoleDebugger implements SmackDebugger {
|
|||
public void connectionClosedOnError(Exception e) {
|
||||
System.out.println(
|
||||
dateFormatter.format(new Date()) +
|
||||
" Connection closed due to an exception (" +
|
||||
" XMPPConnection closed due to an exception (" +
|
||||
connection.hashCode() +
|
||||
")");
|
||||
e.printStackTrace();
|
||||
|
@ -134,13 +134,13 @@ public class ConsoleDebugger implements SmackDebugger {
|
|||
}
|
||||
public void reconnectionSuccessful() {
|
||||
System.out.println(
|
||||
dateFormatter.format(new Date()) + " Connection reconnected (" +
|
||||
dateFormatter.format(new Date()) + " XMPPConnection reconnected (" +
|
||||
connection.hashCode() +
|
||||
")");
|
||||
}
|
||||
public void reconnectingIn(int seconds) {
|
||||
System.out.println(
|
||||
dateFormatter.format(new Date()) + " Connection (" +
|
||||
dateFormatter.format(new Date()) + " XMPPConnection (" +
|
||||
connection.hashCode() +
|
||||
") will reconnect in " + seconds);
|
||||
}
|
||||
|
|
|
@ -39,7 +39,7 @@ public class LiteDebugger implements SmackDebugger {
|
|||
private static final String NEWLINE = "\n";
|
||||
|
||||
private JFrame frame = null;
|
||||
private Connection connection = null;
|
||||
private XMPPConnection connection = null;
|
||||
|
||||
private PacketListener listener = null;
|
||||
|
||||
|
@ -48,7 +48,7 @@ public class LiteDebugger implements SmackDebugger {
|
|||
private ReaderListener readerListener;
|
||||
private WriterListener writerListener;
|
||||
|
||||
public LiteDebugger(Connection connection, Writer writer, Reader reader) {
|
||||
public LiteDebugger(XMPPConnection connection, Writer writer, Reader reader) {
|
||||
this.connection = connection;
|
||||
this.writer = writer;
|
||||
this.reader = reader;
|
||||
|
|
|
@ -26,7 +26,7 @@ import org.jivesoftware.smack.*;
|
|||
* displays XML traffic.<p>
|
||||
*
|
||||
* Every implementation of this interface <b>must</b> have a public constructor with the following
|
||||
* arguments: Connection, Writer, Reader.
|
||||
* arguments: XMPPConnection, Writer, Reader.
|
||||
*
|
||||
* @author Gaston Dombiak
|
||||
*/
|
||||
|
|
|
@ -19,7 +19,7 @@ package org.jivesoftware.smack.filter;
|
|||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import org.jivesoftware.smack.Connection;
|
||||
import org.jivesoftware.smack.XMPPConnection;
|
||||
import org.jivesoftware.smack.packet.IQ;
|
||||
import org.jivesoftware.smack.packet.Packet;
|
||||
import org.jivesoftware.smack.util.StringUtils;
|
||||
|
@ -78,7 +78,7 @@ public class IQReplyFilter implements PacketFilter {
|
|||
*
|
||||
* @param iqPacket An IQ request. Filter for replies to this packet.
|
||||
*/
|
||||
public IQReplyFilter(IQ iqPacket, Connection conn) {
|
||||
public IQReplyFilter(IQ iqPacket, XMPPConnection conn) {
|
||||
to = iqPacket.getTo();
|
||||
if (conn.getUser() == null) {
|
||||
// We have not yet been assigned a username, this can happen if the connection is
|
||||
|
|
|
@ -279,7 +279,7 @@ public class Socks5ProxySocketFactory
|
|||
o X'02' connection not allowed by ruleset
|
||||
o X'03' Network unreachable
|
||||
o X'04' Host unreachable
|
||||
o X'05' Connection refused
|
||||
o X'05' XMPPConnection refused
|
||||
o X'06' TTL expired
|
||||
o X'07' Command not supported
|
||||
o X'08' Address type not supported
|
||||
|
|
|
@ -28,7 +28,7 @@ import java.util.Map;
|
|||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import org.jivesoftware.smack.Connection;
|
||||
import org.jivesoftware.smack.XMPPConnection;
|
||||
import org.jivesoftware.smack.packet.Bind;
|
||||
import org.jivesoftware.smack.packet.DefaultPacketExtension;
|
||||
import org.jivesoftware.smack.packet.IQ;
|
||||
|
@ -281,7 +281,7 @@ public class PacketParserUtils {
|
|||
* @return an IQ object.
|
||||
* @throws Exception if an exception occurs while parsing the packet.
|
||||
*/
|
||||
public static IQ parseIQ(XmlPullParser parser, Connection connection) throws Exception {
|
||||
public static IQ parseIQ(XmlPullParser parser, XMPPConnection connection) throws Exception {
|
||||
IQ iqPacket = null;
|
||||
|
||||
String id = parser.getAttributeValue("", "id");
|
||||
|
|
|
@ -23,7 +23,7 @@ import java.util.concurrent.BlockingQueue;
|
|||
import java.util.concurrent.LinkedBlockingQueue;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.jivesoftware.smack.Connection;
|
||||
import org.jivesoftware.smack.XMPPConnection;
|
||||
import org.jivesoftware.smack.ConnectionConfiguration;
|
||||
import org.jivesoftware.smack.ConnectionCreationListener;
|
||||
import org.jivesoftware.smack.ConnectionListener;
|
||||
|
@ -34,7 +34,7 @@ import org.jivesoftware.smack.packet.Packet;
|
|||
import org.jivesoftware.smack.packet.Presence;
|
||||
|
||||
/**
|
||||
* A dummy implementation of {@link Connection}, intended to be used during
|
||||
* A dummy implementation of {@link XMPPConnection}, intended to be used during
|
||||
* unit tests.
|
||||
*
|
||||
* Instances store any packets that are delivered to be send using the
|
||||
|
@ -49,7 +49,7 @@ import org.jivesoftware.smack.packet.Presence;
|
|||
* @see Connection
|
||||
* @author Guenther Niess
|
||||
*/
|
||||
public class DummyConnection extends Connection {
|
||||
public class DummyConnection extends XMPPConnection {
|
||||
|
||||
private boolean authenticated = false;
|
||||
private boolean anonymous = false;
|
||||
|
|
|
@ -187,7 +187,7 @@ public class PacketCollectorTest
|
|||
|
||||
class TestPacketCollector extends PacketCollector
|
||||
{
|
||||
protected TestPacketCollector(Connection conection, PacketFilter packetFilter, int size)
|
||||
protected TestPacketCollector(XMPPConnection conection, PacketFilter packetFilter, int size)
|
||||
{
|
||||
super(conection, packetFilter, size);
|
||||
}
|
||||
|
|
|
@ -53,7 +53,7 @@ public class RosterTest {
|
|||
@Before
|
||||
public void setUp() throws Exception {
|
||||
// Uncomment this to enable debug output
|
||||
//Connection.DEBUG_ENABLED = true;
|
||||
//XMPPConnection.DEBUG_ENABLED = true;
|
||||
|
||||
connection = new DummyConnection();
|
||||
connection.connect();
|
||||
|
@ -702,7 +702,7 @@ public class RosterTest {
|
|||
|
||||
public synchronized void entriesAdded(Collection<String> addresses) {
|
||||
addressesAdded.addAll(addresses);
|
||||
if (Connection.DEBUG_ENABLED) {
|
||||
if (XMPPConnection.DEBUG_ENABLED) {
|
||||
for (String address : addresses) {
|
||||
System.out.println("Roster entry for " + address + " added.");
|
||||
}
|
||||
|
@ -711,7 +711,7 @@ public class RosterTest {
|
|||
|
||||
public synchronized void entriesDeleted(Collection<String> addresses) {
|
||||
addressesDeleted.addAll(addresses);
|
||||
if (Connection.DEBUG_ENABLED) {
|
||||
if (XMPPConnection.DEBUG_ENABLED) {
|
||||
for (String address : addresses) {
|
||||
System.out.println("Roster entry for " + address + " deleted.");
|
||||
}
|
||||
|
@ -720,7 +720,7 @@ public class RosterTest {
|
|||
|
||||
public synchronized void entriesUpdated(Collection<String> addresses) {
|
||||
addressesUpdated.addAll(addresses);
|
||||
if (Connection.DEBUG_ENABLED) {
|
||||
if (XMPPConnection.DEBUG_ENABLED) {
|
||||
for (String address : addresses) {
|
||||
System.out.println("Roster entry for " + address + " updated.");
|
||||
}
|
||||
|
@ -728,7 +728,7 @@ public class RosterTest {
|
|||
}
|
||||
|
||||
public void presenceChanged(Presence presence) {
|
||||
if (Connection.DEBUG_ENABLED) {
|
||||
if (XMPPConnection.DEBUG_ENABLED) {
|
||||
System.out.println("Roster presence changed: " + presence.toXML());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -57,7 +57,7 @@ public class RosterVersioningTest {
|
|||
@Before
|
||||
public void setUp() throws Exception {
|
||||
// Uncomment this to enable debug output
|
||||
//Connection.DEBUG_ENABLED = true;
|
||||
//XMPPConnection.DEBUG_ENABLED = true;
|
||||
|
||||
DefaultRosterStore store = DefaultRosterStore.init(tmpFolder.newFolder("store"));
|
||||
populateStore(store);
|
||||
|
|
|
@ -19,7 +19,7 @@ package org.jivesoftware.smackx.debugger;
|
|||
|
||||
import org.jivesoftware.smack.ConnectionListener;
|
||||
import org.jivesoftware.smack.PacketListener;
|
||||
import org.jivesoftware.smack.Connection;
|
||||
import org.jivesoftware.smack.XMPPConnection;
|
||||
import org.jivesoftware.smack.debugger.SmackDebugger;
|
||||
import org.jivesoftware.smack.packet.IQ;
|
||||
import org.jivesoftware.smack.packet.Message;
|
||||
|
@ -113,7 +113,7 @@ public class EnhancedDebugger implements SmackDebugger {
|
|||
private JFormattedTextField userField = null;
|
||||
private JFormattedTextField statusField = null;
|
||||
|
||||
private Connection connection = null;
|
||||
private XMPPConnection connection = null;
|
||||
|
||||
private PacketListener packetReaderListener = null;
|
||||
private PacketListener packetWriterListener = null;
|
||||
|
@ -141,7 +141,7 @@ public class EnhancedDebugger implements SmackDebugger {
|
|||
|
||||
JTabbedPane tabbedPane;
|
||||
|
||||
public EnhancedDebugger(Connection connection, Writer writer, Reader reader) {
|
||||
public EnhancedDebugger(XMPPConnection connection, Writer writer, Reader reader) {
|
||||
this.connection = connection;
|
||||
this.writer = writer;
|
||||
this.reader = reader;
|
||||
|
@ -570,7 +570,7 @@ public class EnhancedDebugger implements SmackDebugger {
|
|||
// Add the Host information
|
||||
JPanel connPanel = new JPanel();
|
||||
connPanel.setLayout(new GridBagLayout());
|
||||
connPanel.setBorder(BorderFactory.createTitledBorder("Connection information"));
|
||||
connPanel.setBorder(BorderFactory.createTitledBorder("XMPPConnection information"));
|
||||
|
||||
JLabel label = new JLabel("Host: ");
|
||||
label.setMinimumSize(new java.awt.Dimension(150, 14));
|
||||
|
|
|
@ -121,7 +121,7 @@ public class EnhancedDebuggerWindow {
|
|||
if (frame == null) {
|
||||
createDebug();
|
||||
}
|
||||
debugger.tabbedPane.setName("Connection_" + tabbedPane.getComponentCount());
|
||||
debugger.tabbedPane.setName("XMPPConnection_" + tabbedPane.getComponentCount());
|
||||
tabbedPane.add(debugger.tabbedPane, tabbedPane.getComponentCount() - 1);
|
||||
tabbedPane.setIconAt(tabbedPane.indexOfComponent(debugger.tabbedPane), connectionCreatedIcon);
|
||||
frame.setTitle(
|
||||
|
@ -168,7 +168,7 @@ public class EnhancedDebuggerWindow {
|
|||
int index = getInstance().tabbedPane.indexOfComponent(debugger.tabbedPane);
|
||||
getInstance().tabbedPane.setToolTipTextAt(
|
||||
index,
|
||||
"Connection closed due to the exception: " + e.getMessage());
|
||||
"XMPPConnection closed due to the exception: " + e.getMessage());
|
||||
getInstance().tabbedPane.setIconAt(
|
||||
index,
|
||||
connectionClosedOnErrorIcon);
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
<html>
|
||||
<head>
|
||||
<title>Smack: Connection Management - Jive Software</title>
|
||||
<title>Smack: XMPPConnection Management - Jive Software</title>
|
||||
<link rel="stylesheet" type="text/css" href="style.css"/>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
<div class="header">
|
||||
Smack: Connection Management
|
||||
Smack: XMPPConnection Management
|
||||
</div>
|
||||
|
||||
<div class="nav">
|
||||
|
@ -19,7 +19,7 @@
|
|||
</p>
|
||||
|
||||
<p>
|
||||
The <tt>org.jivesoftware.smack.Connection</tt> class manages your connection to an XMPP
|
||||
The <tt>org.jivesoftware.smack.XMPPConnection</tt> class manages your connection to an XMPP
|
||||
server. The default implementation is the <tt>org.jivesoftware.smack.XMPPConnection</tt>
|
||||
class. Two constructors are mainly used. The first, <tt>XMPPConnection(String)</tt> takes
|
||||
the server name you'd like to connect to as an argument. All default connection settings will
|
||||
|
@ -80,7 +80,7 @@ manager will try to immediately reconnect to the server and increase the delay b
|
|||
successive reconnections keep failing.</i>
|
||||
<br>
|
||||
In case you want to force a reconnection while the reconnetion manager is waiting for the next
|
||||
reconnection, you can just use <i>Connection#connect()</i> and a new attempt will be made.
|
||||
reconnection, you can just use <i>XMPPConnection#connect()</i> and a new attempt will be made.
|
||||
If the manual attempt also failed then the reconnection manager will still continue the
|
||||
reconnection job.
|
||||
</p>
|
||||
|
|
|
@ -26,7 +26,7 @@ Debugging mode can be enabled in two different ways:
|
|||
|
||||
<ol>
|
||||
<li>Add the following line of code <b>before</b> creating new connections:<p>
|
||||
<tt>Connection.DEBUG_ENABLED = true;</tt><p>
|
||||
<tt>XMPPConnection.DEBUG_ENABLED = true;</tt><p>
|
||||
|
||||
<li>Set the Java system property <tt>smack.debugEnabled</tt> to true. The
|
||||
system property can be set on the command line such as:<p>
|
||||
|
@ -39,7 +39,7 @@ add the following line to your application before opening new connections:
|
|||
</p>
|
||||
|
||||
<p>
|
||||
<tt>Connection.DEBUG_ENABLED = false;</tt>
|
||||
<tt>XMPPConnection.DEBUG_ENABLED = false;</tt>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
|
@ -73,7 +73,7 @@ When debugging mode is enabled, a debug window will appear containing tabs for e
|
|||
The window will contain the following information:
|
||||
|
||||
<ul>
|
||||
<li>Connection tabs -- each tab shows debugging information related to the connection.
|
||||
<li>XMPPConnection tabs -- each tab shows debugging information related to the connection.
|
||||
<li>Smack info tab -- shows information about Smack (e.g. Smack version, installed components, etc.).
|
||||
</ul>
|
||||
|
||||
|
|
|
@ -34,9 +34,9 @@ discovery request with the information that you previously configured.</p>
|
|||
<b>Usage</b><p>
|
||||
|
||||
In order to configure the supported features by your client you should first obtain the
|
||||
ServiceDiscoveryManager associated with your Connection. To get your ServiceDiscoveryManager
|
||||
ServiceDiscoveryManager associated with your XMPPConnection. To get your ServiceDiscoveryManager
|
||||
send <b>getInstanceFor(connection)</b> to the class <i><b>ServiceDiscoveryManager</b></i> where
|
||||
connection is your Connection.<br></p>
|
||||
connection is your XMPPConnection.<br></p>
|
||||
|
||||
<p>Once you have your ServiceDiscoveryManager you will be able to manage the supported features. To
|
||||
register a new feature send <b>addFeature(feature)</b> to your <i><b>ServiceDiscoveryManager</b></i>
|
||||
|
@ -48,7 +48,7 @@ String that represents the feature to remove.</p>
|
|||
|
||||
In this example we can see how to add and remove supported features: <br>
|
||||
<blockquote>
|
||||
<pre> <font color="#3f7f5f">// Obtain the ServiceDiscoveryManager associated with my Connection</font>
|
||||
<pre> <font color="#3f7f5f">// Obtain the ServiceDiscoveryManager associated with my XMPPConnection</font>
|
||||
ServiceDiscoveryManager discoManager = ServiceDiscoveryManager.getInstanceFor(connection);
|
||||
|
||||
<font color="#3f7f5f">// Register that a new feature is supported by this XMPP entity</font>
|
||||
|
@ -74,7 +74,7 @@ to configure the information providers associated to the items/nodes within the
|
|||
In order to configure the associated nodes within the Smack client you will need to create a
|
||||
NodeInformationProvider and register it with the <i><b>ServiceDiscoveryManager</b></i>. To get
|
||||
your ServiceDiscoveryManager send <b>getInstanceFor(connection)</b> to the class <i><b>ServiceDiscoveryManager</b></i>
|
||||
where connection is your Connection.<br></p>
|
||||
where connection is your XMPPConnection.<br></p>
|
||||
|
||||
<p>Once you have your ServiceDiscoveryManager you will be able to register information providers
|
||||
for the XMPP entity's nodes. To register a new node information provider send <b>setNodeInformationProvider(String node, NodeInformationProvider listener)</b>
|
||||
|
@ -126,7 +126,7 @@ the discovered items.</p>
|
|||
|
||||
In this example we can see how to discover the items associated with an online catalog service: <br>
|
||||
<blockquote>
|
||||
<pre> <font color="#3f7f5f">// Obtain the ServiceDiscoveryManager associated with my Connection</font>
|
||||
<pre> <font color="#3f7f5f">// Obtain the ServiceDiscoveryManager associated with my XMPPConnection</font>
|
||||
ServiceDiscoveryManager discoManager = ServiceDiscoveryManager.getInstanceFor(connection);
|
||||
|
||||
<font color="#3f7f5f">// Get the items of a given XMPP entity</font>
|
||||
|
@ -171,7 +171,7 @@ the discovered information.</p>
|
|||
|
||||
In this example we can see how to discover the information of a conference room: <br>
|
||||
<blockquote>
|
||||
<pre> <font color="#3f7f5f">// Obtain the ServiceDiscoveryManager associated with my Connection</font>
|
||||
<pre> <font color="#3f7f5f">// Obtain the ServiceDiscoveryManager associated with my XMPPConnection</font>
|
||||
ServiceDiscoveryManager discoManager = ServiceDiscoveryManager.getInstanceFor(connection);
|
||||
|
||||
<font color="#3f7f5f">// Get the information of a given XMPP entity</font>
|
||||
|