2010-02-09 12:55:56 +01:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
* Copyright 2009 Jive Software.
|
|
|
|
*
|
2014-02-17 18:57:38 +01:00
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
2010-02-09 12:55:56 +01:00
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
|
|
|
package org.jivesoftware.smack;
|
|
|
|
|
2014-08-16 00:04:24 +02:00
|
|
|
|
2014-04-03 10:50:23 +02:00
|
|
|
import org.jivesoftware.smack.SmackException.NoResponseException;
|
2014-03-19 14:22:20 +01:00
|
|
|
import org.jivesoftware.smack.SmackException.NotConnectedException;
|
2014-02-23 21:08:35 +01:00
|
|
|
import org.jivesoftware.smack.filter.IQReplyFilter;
|
2010-02-09 12:55:56 +01:00
|
|
|
import org.jivesoftware.smack.filter.PacketFilter;
|
2014-02-23 21:08:35 +01:00
|
|
|
import org.jivesoftware.smack.packet.IQ;
|
2010-02-09 12:55:56 +01:00
|
|
|
import org.jivesoftware.smack.packet.Packet;
|
2014-08-16 14:26:45 +02:00
|
|
|
import org.jivesoftware.smack.rosterstore.RosterStore;
|
2010-02-09 12:55:56 +01:00
|
|
|
|
|
|
|
/**
|
2014-04-15 11:22:46 +02:00
|
|
|
* 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.
|
|
|
|
* {@link XMPPTCPConnection} or {@link XMPPBOSHConnection}). To create a connection to a XMPP server
|
|
|
|
* a simple usage of this API might look like the following:
|
|
|
|
* <p>
|
2010-02-09 12:55:56 +01:00
|
|
|
*
|
|
|
|
* <pre>
|
|
|
|
* // Create a connection to the igniterealtime.org XMPP server.
|
2014-04-09 12:16:44 +02:00
|
|
|
* XMPPConnection con = new XMPPTCPConnection("igniterealtime.org");
|
2010-02-09 12:55:56 +01:00
|
|
|
* // Connect to the server
|
|
|
|
* con.connect();
|
|
|
|
* // Most servers require you to login before performing other tasks.
|
|
|
|
* con.login("jsmith", "mypass");
|
|
|
|
* // Start a new conversation with John Doe and send him a message.
|
2014-04-15 11:22:46 +02:00
|
|
|
* Chat chat = ChatManager.getInstanceFor(con).createChat(<font color="green">"jdoe@igniterealtime.org"</font>, new MessageListener() {
|
2010-02-09 12:55:56 +01:00
|
|
|
* public void processMessage(Chat chat, Message message) {
|
|
|
|
* // Print out any messages we get back to standard out.
|
|
|
|
* System.out.println(<font color="green">"Received message: "</font> + message);
|
|
|
|
* }
|
|
|
|
* });
|
|
|
|
* chat.sendMessage(<font color="green">"Howdy!"</font>);
|
|
|
|
* // Disconnect from the server
|
|
|
|
* con.disconnect();
|
|
|
|
* </pre>
|
2014-04-15 11:22:46 +02:00
|
|
|
* <p>
|
|
|
|
* Connections can be reused between connections. This means that an Connection may be connected,
|
2014-05-25 12:28:08 +02:00
|
|
|
* disconnected and then connected again. Listeners of the Connection will be retained across
|
2014-04-15 11:22:46 +02:00
|
|
|
* connections.
|
2010-02-09 12:55:56 +01:00
|
|
|
*
|
|
|
|
* @author Matt Tucker
|
|
|
|
* @author Guenther Niess
|
|
|
|
*/
|
2014-04-27 12:27:12 +02:00
|
|
|
@SuppressWarnings("javadoc")
|
2014-05-25 12:28:08 +02:00
|
|
|
public interface XMPPConnection {
|
2010-02-09 12:55:56 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the name of the service provided by the XMPP server for this connection.
|
|
|
|
* This is also called XMPP domain of the connected server. After
|
|
|
|
* authenticating with the server the returned value may be different.
|
|
|
|
*
|
|
|
|
* @return the name of the service provided by the XMPP server.
|
|
|
|
*/
|
2014-05-25 12:28:08 +02:00
|
|
|
public String getServiceName();
|
2010-02-09 12:55:56 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the host name of the server where the XMPP server is running. This would be the
|
|
|
|
* IP address of the server or a name that may be resolved by a DNS server.
|
|
|
|
*
|
2014-03-18 09:27:45 +01:00
|
|
|
* @return the host name of the server where the XMPP server is running or null if not yet connected.
|
2010-02-09 12:55:56 +01:00
|
|
|
*/
|
2014-05-25 12:28:08 +02:00
|
|
|
public String getHost();
|
2010-02-09 12:55:56 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the port number of the XMPP server for this connection. The default port
|
2014-03-18 09:27:45 +01:00
|
|
|
* for normal connections is 5222.
|
2010-02-09 12:55:56 +01:00
|
|
|
*
|
2014-03-18 09:27:45 +01:00
|
|
|
* @return the port number of the XMPP server or 0 if not yet connected.
|
2010-02-09 12:55:56 +01:00
|
|
|
*/
|
2014-05-25 12:28:08 +02:00
|
|
|
public int getPort();
|
2010-02-09 12:55:56 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the full XMPP address of the user that is logged in to the connection or
|
|
|
|
* <tt>null</tt> if not logged in yet. An XMPP address is in the form
|
|
|
|
* username@server/resource.
|
|
|
|
*
|
|
|
|
* @return the full XMPP address of the user logged in.
|
|
|
|
*/
|
2014-05-25 12:28:08 +02:00
|
|
|
public String getUser();
|
2010-02-09 12:55:56 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the connection ID for this connection, which is the value set by the server
|
|
|
|
* when opening a XMPP stream. If the server does not set a connection ID, this value
|
|
|
|
* will be null. This value will be <tt>null</tt> if not connected to the server.
|
|
|
|
*
|
|
|
|
* @return the ID of this connection returned from the XMPP server or <tt>null</tt> if
|
|
|
|
* not connected to the server.
|
|
|
|
*/
|
2014-05-25 12:28:08 +02:00
|
|
|
public String getConnectionID();
|
2010-02-09 12:55:56 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns true if currently connected to the XMPP server.
|
|
|
|
*
|
|
|
|
* @return true if connected.
|
|
|
|
*/
|
2014-05-25 12:28:08 +02:00
|
|
|
public boolean isConnected();
|
2010-02-09 12:55:56 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns true if currently authenticated by successfully calling the login method.
|
|
|
|
*
|
|
|
|
* @return true if authenticated.
|
|
|
|
*/
|
2014-05-25 12:28:08 +02:00
|
|
|
public boolean isAuthenticated();
|
2010-02-09 12:55:56 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns true if currently authenticated anonymously.
|
|
|
|
*
|
|
|
|
* @return true if authenticated anonymously.
|
|
|
|
*/
|
2014-05-25 12:28:08 +02:00
|
|
|
public boolean isAnonymous();
|
2010-02-09 12:55:56 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns true if the connection to the server has successfully negotiated encryption.
|
|
|
|
*
|
|
|
|
* @return true if a secure connection to the server.
|
|
|
|
*/
|
2014-05-25 12:28:08 +02:00
|
|
|
public boolean isSecureConnection();
|
2014-03-17 19:33:17 +01:00
|
|
|
|
2010-02-09 12:55:56 +01:00
|
|
|
/**
|
|
|
|
* Returns true if network traffic is being compressed. When using stream compression network
|
|
|
|
* traffic can be reduced up to 90%. Therefore, stream compression is ideal when using a slow
|
|
|
|
* speed network connection. However, the server will need to use more CPU time in order to
|
|
|
|
* un/compress network data so under high load the server performance might be affected.
|
|
|
|
*
|
|
|
|
* @return true if network traffic is being compressed.
|
|
|
|
*/
|
2014-05-25 12:28:08 +02:00
|
|
|
public boolean isUsingCompression();
|
2010-02-09 12:55:56 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Sends the specified packet to the server.
|
|
|
|
*
|
|
|
|
* @param packet the packet to send.
|
2014-03-19 14:22:20 +01:00
|
|
|
* @throws NotConnectedException
|
2010-02-09 12:55:56 +01:00
|
|
|
*/
|
2014-05-25 12:28:08 +02:00
|
|
|
public void sendPacket(Packet packet) throws NotConnectedException;
|
2010-02-09 12:55:56 +01:00
|
|
|
|
|
|
|
/**
|
2010-08-15 18:32:09 +02:00
|
|
|
* Returns the roster for the user.
|
|
|
|
* <p>
|
|
|
|
* This method will never return <code>null</code>, instead if the user has not yet logged into
|
|
|
|
* the server or is logged in anonymously all modifying methods of the returned roster object
|
|
|
|
* like {@link Roster#createEntry(String, String, String[])},
|
|
|
|
* {@link Roster#removeEntry(RosterEntry)} , etc. except adding or removing
|
|
|
|
* {@link RosterListener}s will throw an IllegalStateException.
|
2010-02-09 12:55:56 +01:00
|
|
|
*
|
2010-08-15 18:32:09 +02:00
|
|
|
* @return the user's roster.
|
2014-03-14 01:48:33 +01:00
|
|
|
* @throws IllegalStateException if the connection is anonymous
|
2010-02-09 12:55:56 +01:00
|
|
|
*/
|
2014-05-25 12:28:08 +02:00
|
|
|
public Roster getRoster();
|
2010-02-09 12:55:56 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Adds a connection listener to this connection that will be notified when
|
2013-11-02 12:46:21 +01:00
|
|
|
* the connection closes or fails.
|
2010-02-09 12:55:56 +01:00
|
|
|
*
|
|
|
|
* @param connectionListener a connection listener.
|
|
|
|
*/
|
2014-05-25 12:28:08 +02:00
|
|
|
public void addConnectionListener(ConnectionListener connectionListener);
|
2010-02-09 12:55:56 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Removes a connection listener from this connection.
|
|
|
|
*
|
|
|
|
* @param connectionListener a connection listener.
|
|
|
|
*/
|
2014-05-25 12:28:08 +02:00
|
|
|
public void removeConnectionListener(ConnectionListener connectionListener);
|
2010-02-09 12:55:56 +01:00
|
|
|
|
2014-02-18 15:05:19 +01:00
|
|
|
/**
|
|
|
|
* Creates a new packet collector collecting packets that are replies to <code>packet</code>.
|
2014-02-23 21:08:35 +01:00
|
|
|
* Does also send <code>packet</code>. The packet filter for the collector is an
|
|
|
|
* {@link IQReplyFilter}, guaranteeing that packet id and JID in the 'from' address have
|
|
|
|
* expected values.
|
|
|
|
*
|
2014-02-18 15:05:19 +01:00
|
|
|
* @param packet the packet to filter responses from
|
|
|
|
* @return a new packet collector.
|
2014-03-19 14:22:20 +01:00
|
|
|
* @throws NotConnectedException
|
2014-02-18 15:05:19 +01:00
|
|
|
*/
|
2014-05-25 12:28:08 +02:00
|
|
|
public PacketCollector createPacketCollectorAndSend(IQ packet) throws NotConnectedException;
|
2014-02-18 15:05:19 +01:00
|
|
|
|
2010-02-09 12:55:56 +01:00
|
|
|
/**
|
|
|
|
* Creates a new packet collector for this connection. A packet filter determines
|
|
|
|
* which packets will be accumulated by the collector. A PacketCollector is
|
|
|
|
* more suitable to use than a {@link PacketListener} when you need to wait for
|
|
|
|
* a specific result.
|
|
|
|
*
|
|
|
|
* @param packetFilter the packet filter to use.
|
|
|
|
* @return a new packet collector.
|
|
|
|
*/
|
2014-05-25 12:28:08 +02:00
|
|
|
public PacketCollector createPacketCollector(PacketFilter packetFilter);
|
2010-02-09 12:55:56 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Remove a packet collector of this connection.
|
|
|
|
*
|
|
|
|
* @param collector a packet collectors which was created for this connection.
|
|
|
|
*/
|
2014-05-25 12:28:08 +02:00
|
|
|
public void removePacketCollector(PacketCollector collector);
|
2010-02-09 12:55:56 +01:00
|
|
|
|
|
|
|
/**
|
2014-01-20 03:52:44 +01:00
|
|
|
* Registers a packet listener with this connection. A packet listener will be invoked only
|
|
|
|
* when an incoming packet is received. A packet filter determines
|
2010-02-09 12:55:56 +01:00
|
|
|
* which packets will be delivered to the listener. If the same packet listener
|
|
|
|
* is added again with a different filter, only the new filter will be used.
|
|
|
|
*
|
2014-01-20 03:52:44 +01:00
|
|
|
* NOTE: If you want get a similar callback for outgoing packets, see {@link #addPacketInterceptor(PacketInterceptor, PacketFilter)}.
|
|
|
|
*
|
2010-02-09 12:55:56 +01:00
|
|
|
* @param packetListener the packet listener to notify of new received packets.
|
|
|
|
* @param packetFilter the packet filter to use.
|
|
|
|
*/
|
2014-05-25 12:28:08 +02:00
|
|
|
public void addPacketListener(PacketListener packetListener, PacketFilter packetFilter);
|
2010-02-09 12:55:56 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Removes a packet listener for received packets from this connection.
|
|
|
|
*
|
|
|
|
* @param packetListener the packet listener to remove.
|
2014-08-16 00:04:24 +02:00
|
|
|
* @return true if the packet listener was removed
|
2010-02-09 12:55:56 +01:00
|
|
|
*/
|
2014-08-16 00:04:24 +02:00
|
|
|
public boolean removePacketListener(PacketListener packetListener);
|
2010-02-09 12:55:56 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Registers a packet listener with this connection. The listener will be
|
|
|
|
* notified of every packet that this connection sends. A packet filter determines
|
|
|
|
* which packets will be delivered to the listener. Note that the thread
|
|
|
|
* that writes packets will be used to invoke the listeners. Therefore, each
|
|
|
|
* packet listener should complete all operations quickly or use a different
|
|
|
|
* thread for processing.
|
|
|
|
*
|
|
|
|
* @param packetListener the packet listener to notify of sent packets.
|
|
|
|
* @param packetFilter the packet filter to use.
|
|
|
|
*/
|
2014-05-25 12:28:08 +02:00
|
|
|
public void addPacketSendingListener(PacketListener packetListener, PacketFilter packetFilter);
|
2010-02-09 12:55:56 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Removes a packet listener for sending packets from this connection.
|
|
|
|
*
|
|
|
|
* @param packetListener the packet listener to remove.
|
|
|
|
*/
|
2014-05-25 12:28:08 +02:00
|
|
|
public void removePacketSendingListener(PacketListener packetListener);
|
2010-02-09 12:55:56 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Registers a packet interceptor with this connection. The interceptor will be
|
|
|
|
* invoked every time a packet is about to be sent by this connection. Interceptors
|
|
|
|
* may modify the packet to be sent. A packet filter determines which packets
|
|
|
|
* will be delivered to the interceptor.
|
2014-01-20 03:52:44 +01:00
|
|
|
*
|
|
|
|
* <p>
|
|
|
|
* NOTE: For a similar functionality on incoming packets, see {@link #addPacketListener(PacketListener, PacketFilter)}.
|
2010-02-09 12:55:56 +01:00
|
|
|
*
|
|
|
|
* @param packetInterceptor the packet interceptor to notify of packets about to be sent.
|
|
|
|
* @param packetFilter the packet filter to use.
|
|
|
|
*/
|
2014-05-25 12:28:08 +02:00
|
|
|
public void addPacketInterceptor(PacketInterceptor packetInterceptor, PacketFilter packetFilter);
|
|
|
|
|
2010-02-09 12:55:56 +01:00
|
|
|
/**
|
|
|
|
* Removes a packet interceptor.
|
|
|
|
*
|
|
|
|
* @param packetInterceptor the packet interceptor to remove.
|
|
|
|
*/
|
2014-05-25 12:28:08 +02:00
|
|
|
public void removePacketInterceptor(PacketInterceptor packetInterceptor);
|
2010-02-09 12:55:56 +01:00
|
|
|
|
2013-03-18 09:50:48 +01:00
|
|
|
/**
|
|
|
|
* Retrieve the servers Entity Caps node
|
|
|
|
*
|
2014-03-10 09:45:50 +01:00
|
|
|
* XMPPConnection holds this information in order to avoid a dependency to
|
2013-03-18 09:50:48 +01:00
|
|
|
* smackx where EntityCapsManager lives from smack.
|
|
|
|
*
|
2014-03-10 18:31:45 +01:00
|
|
|
* @return the servers entity caps node
|
2013-03-18 09:50:48 +01:00
|
|
|
*/
|
2014-05-25 12:28:08 +02:00
|
|
|
public String getServiceCapsNode();
|
2010-02-09 12:55:56 +01:00
|
|
|
|
2013-11-10 15:02:57 +01:00
|
|
|
/**
|
|
|
|
* Returns true if the server supports roster versioning as defined in XEP-0237.
|
|
|
|
*
|
|
|
|
* @return true if the server supports roster versioning
|
|
|
|
*/
|
2014-05-25 12:28:08 +02:00
|
|
|
public boolean isRosterVersioningSupported();
|
2013-11-10 15:02:57 +01:00
|
|
|
|
2014-04-03 10:50:23 +02:00
|
|
|
/**
|
|
|
|
* Returns the current value of the reply timeout in milliseconds for request for this
|
|
|
|
* XMPPConnection instance.
|
|
|
|
*
|
|
|
|
* @return the packet reply timeout in milliseconds
|
|
|
|
*/
|
2014-05-25 12:28:08 +02:00
|
|
|
public long getPacketReplyTimeout();
|
2014-02-18 15:05:19 +01:00
|
|
|
|
2014-03-14 00:25:22 +01:00
|
|
|
/**
|
2014-04-03 10:50:23 +02:00
|
|
|
* Set the packet reply timeout in milliseconds. In most cases, Smack will throw a
|
|
|
|
* {@link NoResponseException} if no reply to a request was received within the timeout period.
|
|
|
|
*
|
|
|
|
* @param timeout the packet reply timeout in milliseconds
|
|
|
|
*/
|
2014-05-25 12:28:08 +02:00
|
|
|
public void setPacketReplyTimeout(long timeout);
|
2014-03-15 11:39:38 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the connection counter of this XMPPConnection instance. Those can be used as ID to
|
|
|
|
* identify the connection, but beware that the ID may not be unique if you create more then
|
|
|
|
* <tt>2*Integer.MAX_VALUE</tt> instances as the counter could wrap.
|
|
|
|
*
|
|
|
|
* @return the connection counter of this XMPPConnection
|
|
|
|
*/
|
2014-05-25 12:28:08 +02:00
|
|
|
public int getConnectionCounter();
|
2014-04-14 09:07:42 +02:00
|
|
|
|
|
|
|
public static enum FromMode {
|
|
|
|
/**
|
|
|
|
* Leave the 'from' attribute unchanged. This is the behavior of Smack < 4.0
|
|
|
|
*/
|
|
|
|
UNCHANGED,
|
|
|
|
/**
|
|
|
|
* Omit the 'from' attribute. According to RFC 6120 8.1.2.1 1. XMPP servers "MUST (...)
|
|
|
|
* override the 'from' attribute specified by the client". It is therefore safe to specify
|
|
|
|
* FromMode.OMITTED here.
|
|
|
|
*/
|
|
|
|
OMITTED,
|
|
|
|
/**
|
|
|
|
* Set the from to the clients full JID. This is usually not required.
|
|
|
|
*/
|
|
|
|
USER
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set the FromMode for this connection instance. Defines how the 'from' attribute of outgoing
|
|
|
|
* stanzas should be populated by Smack.
|
|
|
|
*
|
|
|
|
* @param fromMode
|
|
|
|
*/
|
2014-05-25 12:28:08 +02:00
|
|
|
public void setFromMode(FromMode fromMode);
|
2014-04-14 09:07:42 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the currently active FromMode.
|
|
|
|
*
|
|
|
|
* @return the currently active {@link FromMode}
|
|
|
|
*/
|
2014-05-25 12:28:08 +02:00
|
|
|
public FromMode getFromMode();
|
2014-06-05 03:27:16 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the permanent roster store.
|
|
|
|
* @return the permanent roster store or null
|
|
|
|
*/
|
|
|
|
public RosterStore getRosterStore();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns true if the roster will be loaded from the server when logging in. This
|
|
|
|
* is the common behaviour for clients but sometimes clients may want to differ this
|
|
|
|
* or just never do it if not interested in rosters.
|
|
|
|
*
|
|
|
|
* @return true if the roster will be loaded from the server when logging in.
|
|
|
|
*/
|
|
|
|
public boolean isRosterLoadedAtLogin();
|
2014-08-16 00:04:24 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Send a stanza and wait asynchronously for a response by using <code>replyFilter</code>.
|
|
|
|
* <p>
|
|
|
|
* If there is a response, then <code>callback</code> will be invoked. The callback will be
|
|
|
|
* invoked at most once and it will be not invoked after the connections default reply timeout
|
|
|
|
* has been elapsed.
|
|
|
|
* </p>
|
|
|
|
*
|
|
|
|
* @param stanza the stanza to send (required)
|
|
|
|
* @param replyFilter the filter used to determine response stanza (required)
|
|
|
|
* @param callback the callback invoked if there is a response (required)
|
|
|
|
* @throws NotConnectedException
|
|
|
|
*/
|
|
|
|
public void sendStanzaWithResponseCallback(Packet stanza, PacketFilter replyFilter,
|
|
|
|
PacketListener callback) throws NotConnectedException;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Send a stanza and wait asynchronously for a response by using <code>replyFilter</code>.
|
|
|
|
* <p>
|
|
|
|
* If there is a response, then <code>callback</code> will be invoked. If there is no response
|
|
|
|
* after the connections default reply timeout, then <code>exceptionCallback</code> will be invoked
|
|
|
|
* with a {@link SmackException.NoResponseException}. The callback will be invoked at most once.
|
|
|
|
* </p>
|
|
|
|
*
|
|
|
|
* @param stanza the stanza to send (required)
|
|
|
|
* @param replyFilter the filter used to determine response stanza (required)
|
|
|
|
* @param callback the callback invoked if there is a response (required)
|
|
|
|
* @param exceptionCallback the callback invoked if there is an exception (optional)
|
|
|
|
* @throws NotConnectedException
|
|
|
|
*/
|
|
|
|
public void sendStanzaWithResponseCallback(Packet stanza, PacketFilter replyFilter, PacketListener callback,
|
|
|
|
ExceptionCallback exceptionCallback) throws NotConnectedException;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Send a stanza and wait asynchronously for a response by using <code>replyFilter</code>.
|
|
|
|
* <p>
|
|
|
|
* If there is a response, then <code>callback</code> will be invoked. If there is no response
|
|
|
|
* after <code>timeout</code> milliseconds, then <code>exceptionCallback</code> will be invoked
|
|
|
|
* with a {@link SmackException.NoResponseException}. The callback will be invoked at most once.
|
|
|
|
* </p>
|
|
|
|
*
|
|
|
|
* @param stanza the stanza to send (required)
|
|
|
|
* @param replyFilter the filter used to determine response stanza (required)
|
|
|
|
* @param callback the callback invoked if there is a response (required)
|
|
|
|
* @param exceptionCallback the callback invoked if there is an exception (optional)
|
|
|
|
* @param timeout the timeout in milliseconds to wait for a response
|
|
|
|
* @throws NotConnectedException
|
|
|
|
*/
|
|
|
|
public void sendStanzaWithResponseCallback(Packet stanza, PacketFilter replyFilter,
|
|
|
|
final PacketListener callback, final ExceptionCallback exceptionCallback,
|
|
|
|
long timeout) throws NotConnectedException;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Send a IQ stanza and invoke <code>callback</code> if there is a result of
|
|
|
|
* {@link org.jivesoftware.smack.packet.IQ.Type#result} with that result IQ. The callback will
|
|
|
|
* not be invoked after the connections default reply timeout has been elapsed.
|
|
|
|
*
|
|
|
|
* @param iqRequest the IQ stanza to send (required)
|
|
|
|
* @param callback the callback invoked if there is result response (required)
|
|
|
|
* @throws NotConnectedException
|
|
|
|
*/
|
|
|
|
public void sendIqWithResponseCallback(IQ iqRequest, PacketListener callback) throws NotConnectedException;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Send a IQ stanza and invoke <code>callback</code> if there is a result of
|
|
|
|
* {@link org.jivesoftware.smack.packet.IQ.Type#result} with that result IQ. If there is an
|
|
|
|
* error response <code>exceptionCallback</code> will be invoked, if not null, with the received
|
|
|
|
* error as {@link XMPPException.XMPPErrorException}. If there is no response after the
|
|
|
|
* connections default reply timeout, then <code>exceptionCallback</code> will be invoked with a
|
|
|
|
* {@link SmackException.NoResponseException}.
|
|
|
|
*
|
|
|
|
* @param iqRequest the IQ stanza to send (required)
|
|
|
|
* @param callback the callback invoked if there is result response (required)
|
|
|
|
* @param exceptionCallback the callback invoked if there is an Exception optional
|
|
|
|
* @throws NotConnectedException
|
|
|
|
*/
|
|
|
|
public void sendIqWithResponseCallback(IQ iqRequest, PacketListener callback,
|
|
|
|
ExceptionCallback exceptionCallback) throws NotConnectedException;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Send a IQ stanza and invoke <code>callback</code> if there is a result of
|
|
|
|
* {@link org.jivesoftware.smack.packet.IQ.Type#result} with that result IQ. If there is an
|
|
|
|
* error response <code>exceptionCallback</code> will be invoked, if not null, with the received
|
|
|
|
* error as {@link XMPPException.XMPPErrorException}. If there is no response after
|
|
|
|
* <code>timeout</code>, then <code>exceptionCallback</code> will be invoked with a
|
|
|
|
* {@link SmackException.NoResponseException}.
|
|
|
|
*
|
|
|
|
* @param iqRequest the IQ stanza to send (required)
|
|
|
|
* @param callback the callback invoked if there is result response (required)
|
|
|
|
* @param exceptionCallback the callback invoked if there is an Exception optional
|
|
|
|
* @param timeout the timeout in milliseconds to wait for a response
|
|
|
|
* @throws NotConnectedException
|
|
|
|
*/
|
|
|
|
public void sendIqWithResponseCallback(IQ iqRequest, final PacketListener callback,
|
|
|
|
final ExceptionCallback exceptionCallback, long timeout)
|
|
|
|
throws NotConnectedException;
|
2014-08-20 10:33:52 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the timestamp in milliseconds when the last stanza was received.
|
|
|
|
*
|
|
|
|
* @return the timestamp in milliseconds
|
|
|
|
*/
|
|
|
|
public long getLastStanzaReceived();
|
2010-02-09 12:55:56 +01:00
|
|
|
}
|