mirror of
https://codeberg.org/Mercury-IM/Smack
synced 2025-09-11 11:19:41 +02:00
Move getRoster() to XMPPConnection
Also remove the Exceptions from the signature of getRoster(). Extend ConnectionListener with connected() and authenticated() callbacks, required by Roster to be notified so that the Roster can be loaded *after* login.
This commit is contained in:
parent
4b56446e40
commit
64e7b8a868
15 changed files with 193 additions and 260 deletions
|
@ -27,8 +27,8 @@ import java.util.Map;
|
|||
import java.util.Random;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import org.jivesoftware.smack.AbstractConnectionListener;
|
||||
import org.jivesoftware.smack.XMPPConnection;
|
||||
import org.jivesoftware.smack.ConnectionListener;
|
||||
import org.jivesoftware.smack.PacketCollector;
|
||||
import org.jivesoftware.smack.XMPPException.XMPPErrorException;
|
||||
import org.jivesoftware.smack.packet.IQ;
|
||||
|
@ -215,26 +215,16 @@ public class FileTransferNegotiator {
|
|||
}
|
||||
|
||||
private void configureConnection(final XMPPConnection connection) {
|
||||
connection.addConnectionListener(new ConnectionListener() {
|
||||
connection.addConnectionListener(new AbstractConnectionListener() {
|
||||
@Override
|
||||
public void connectionClosed() {
|
||||
cleanup(connection);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void connectionClosedOnError(Exception e) {
|
||||
cleanup(connection);
|
||||
}
|
||||
|
||||
public void reconnectionFailed(Exception e) {
|
||||
// ignore
|
||||
}
|
||||
|
||||
public void reconnectionSuccessful() {
|
||||
// ignore
|
||||
}
|
||||
|
||||
public void reconnectingIn(int seconds) {
|
||||
// ignore
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -32,9 +32,9 @@ import java.util.concurrent.ConcurrentHashMap;
|
|||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import org.jivesoftware.smack.AbstractConnectionListener;
|
||||
import org.jivesoftware.smack.Chat;
|
||||
import org.jivesoftware.smack.ConnectionCreationListener;
|
||||
import org.jivesoftware.smack.ConnectionListener;
|
||||
import org.jivesoftware.smack.MessageListener;
|
||||
import org.jivesoftware.smack.PacketCollector;
|
||||
import org.jivesoftware.smack.PacketInterceptor;
|
||||
|
@ -2338,7 +2338,7 @@ public class MultiUserChat {
|
|||
*
|
||||
* @author Gaston Dombiak
|
||||
*/
|
||||
private static class InvitationsMonitor implements ConnectionListener {
|
||||
private static class InvitationsMonitor extends AbstractConnectionListener {
|
||||
// We use a WeakHashMap so that the GC can collect the monitor when the
|
||||
// connection is no longer referenced by any object.
|
||||
// Note that when the InvitationsMonitor is used, i.e. when there are InvitationListeners, it will add a
|
||||
|
@ -2447,26 +2447,11 @@ public class MultiUserChat {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void connectionClosed() {
|
||||
cancel();
|
||||
}
|
||||
|
||||
public void connectionClosedOnError(Exception e) {
|
||||
// ignore
|
||||
}
|
||||
|
||||
public void reconnectingIn(int seconds) {
|
||||
// ignore
|
||||
}
|
||||
|
||||
public void reconnectionSuccessful() {
|
||||
// ignore
|
||||
}
|
||||
|
||||
public void reconnectionFailed(Exception e) {
|
||||
// ignore
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the listeners to detect received room invitations and to detect when the
|
||||
* connection gets closed. As soon as a room invitation is received the invitations
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
|
||||
package org.jivesoftware.smackx.muc;
|
||||
|
||||
import org.jivesoftware.smack.ConnectionListener;
|
||||
import org.jivesoftware.smack.AbstractConnectionListener;
|
||||
import org.jivesoftware.smack.PacketListener;
|
||||
import org.jivesoftware.smack.XMPPConnection;
|
||||
import org.jivesoftware.smack.filter.PacketFilter;
|
||||
|
@ -38,7 +38,7 @@ import java.util.concurrent.ConcurrentHashMap;
|
|||
*
|
||||
* @author Larry Kirschner
|
||||
*/
|
||||
class RoomListenerMultiplexor implements ConnectionListener {
|
||||
class RoomListenerMultiplexor extends AbstractConnectionListener {
|
||||
|
||||
// We use a WeakHashMap so that the GC can collect the monitor when the
|
||||
// connection is no longer referenced by any object.
|
||||
|
@ -98,26 +98,16 @@ class RoomListenerMultiplexor implements ConnectionListener {
|
|||
listener.addRoom(address, roomListener);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void connectionClosed() {
|
||||
cancel();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void connectionClosedOnError(Exception e) {
|
||||
cancel();
|
||||
}
|
||||
|
||||
public void reconnectingIn(int seconds) {
|
||||
// ignore
|
||||
}
|
||||
|
||||
public void reconnectionSuccessful() {
|
||||
// ignore
|
||||
}
|
||||
|
||||
public void reconnectionFailed(Exception e) {
|
||||
// ignore
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the listeners to detect received room invitations and to detect when the
|
||||
* connection gets closed. As soon as a room invitation is received the invitations
|
||||
|
|
|
@ -26,11 +26,11 @@ import java.util.concurrent.TimeUnit;
|
|||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import org.jivesoftware.smack.AbstractConnectionListener;
|
||||
import org.jivesoftware.smack.SmackException;
|
||||
import org.jivesoftware.smack.SmackException.NoResponseException;
|
||||
import org.jivesoftware.smack.XMPPConnection;
|
||||
import org.jivesoftware.smack.ConnectionCreationListener;
|
||||
import org.jivesoftware.smack.ConnectionListener;
|
||||
import org.jivesoftware.smack.Manager;
|
||||
import org.jivesoftware.smack.PacketListener;
|
||||
import org.jivesoftware.smack.XMPPException;
|
||||
|
@ -134,7 +134,11 @@ public class PingManager extends Manager {
|
|||
connection().sendPacket(pong);
|
||||
}
|
||||
}, PING_PACKET_FILTER);
|
||||
connection.addConnectionListener(new ConnectionListener() {
|
||||
connection.addConnectionListener(new AbstractConnectionListener() {
|
||||
@Override
|
||||
public void authenticated(XMPPConnection connection) {
|
||||
maybeSchedulePingServerTask();
|
||||
}
|
||||
@Override
|
||||
public void connectionClosed() {
|
||||
maybeStopPingServerTask();
|
||||
|
@ -143,14 +147,6 @@ public class PingManager extends Manager {
|
|||
public void connectionClosedOnError(Exception arg0) {
|
||||
maybeStopPingServerTask();
|
||||
}
|
||||
@Override
|
||||
public void reconnectionSuccessful() {
|
||||
maybeSchedulePingServerTask();
|
||||
}
|
||||
@Override
|
||||
public void reconnectingIn(int seconds) {}
|
||||
@Override
|
||||
public void reconnectionFailed(Exception e) {}
|
||||
});
|
||||
maybeSchedulePingServerTask();
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue