1
0
Fork 0
mirror of https://codeberg.org/Mercury-IM/Smack synced 2024-11-23 06:42:05 +01:00

Added login method to make sending presence optional (SMACK-52).

git-svn-id: http://svn.igniterealtime.org/svn/repos/smack/trunk@2496 b35dd754-fafc-0310-a699-88a17e54d16e
This commit is contained in:
Matt Tucker 2005-06-02 04:52:40 +00:00 committed by matt
parent 1d50de1107
commit 51f29937d2

View file

@ -226,8 +226,8 @@ public class XMPPConnection {
/**
* Logs in to the server using the strongest authentication mode supported by
* the server, then set our presence to available. If more than five seconds
* elapses in each step of the authentication process without a response from
* the server, or if an error occurs, a XMPPException will be thrown.
* (default timeout) elapses in each step of the authentication process without
* a response from the server, or if an error occurs, a XMPPException will be thrown.
*
* @param username the username.
* @param password the password.
@ -240,8 +240,8 @@ public class XMPPConnection {
/**
* Logs in to the server using the strongest authentication mode supported by
* the server, then sets presence to available. If more than five seconds
* elapses in each step of the authentication process without a response from
* the server, or if an error occurs, a XMPPException will be thrown.
* (default timeout) elapses in each step of the authentication process without
* a response from the server, or if an error occurs, a XMPPException will be thrown.
*
* @param username the username.
* @param password the password.
@ -251,7 +251,30 @@ public class XMPPConnection {
* to the serrver.
*/
public synchronized void login(String username, String password, String resource)
throws XMPPException {
throws XMPPException
{
login(username, password, resource, true);
}
/**
* Logs in to the server using the strongest authentication mode supported by
* the server, and optionally sends an available presence. if <tt>sendPresence</tt>
* is false, a presence packet must be sent manually later. If more than five seconds
* (default timeout) elapses in each step of the authentication process without a
* response from the server, or if an error occurs, a XMPPException will be thrown.
*
* @param username the username.
* @param password the password.
* @param resource the resource.
* @param sendPresence if <tt>true</tt> an available presence will be sent automatically
* after login is completed.
* @throws XMPPException if an error occurs.
* @throws IllegalStateException if not connected to the server, or already logged in
* to the serrver.
*/
public synchronized void login(String username, String password, String resource,
boolean sendPresence) throws XMPPException
{
if (!isConnected()) {
throw new IllegalStateException("Not connected to server.");
}
@ -329,7 +352,9 @@ public class XMPPConnection {
roster.reload();
// Set presence to online.
packetWriter.sendPacket(new Presence(Presence.Type.AVAILABLE));
if (sendPresence) {
packetWriter.sendPacket(new Presence(Presence.Type.AVAILABLE));
}
// Indicate that we're now authenticated.
authenticated = true;