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-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;
|
2018-03-31 14:15:46 +02:00
|
|
|
import org.jivesoftware.smack.XMPPException.XMPPErrorException;
|
2014-02-23 21:08:35 +01:00
|
|
|
import org.jivesoftware.smack.filter.IQReplyFilter;
|
2015-02-26 18:41:17 +01:00
|
|
|
import org.jivesoftware.smack.filter.StanzaFilter;
|
2015-01-08 11:01:35 +01:00
|
|
|
import org.jivesoftware.smack.iqrequest.IQRequestHandler;
|
2015-02-26 18:41:17 +01:00
|
|
|
import org.jivesoftware.smack.packet.ExtensionElement;
|
2017-06-14 17:12:43 +02:00
|
|
|
import org.jivesoftware.smack.packet.IQ;
|
2015-07-14 22:41:33 +02:00
|
|
|
import org.jivesoftware.smack.packet.Nonza;
|
2017-06-14 17:12:43 +02:00
|
|
|
import org.jivesoftware.smack.packet.Stanza;
|
|
|
|
|
2015-02-14 17:15:02 +01:00
|
|
|
import org.jxmpp.jid.DomainBareJid;
|
2015-05-27 19:29:51 +02:00
|
|
|
import org.jxmpp.jid.EntityFullJid;
|
2010-02-09 12:55:56 +01:00
|
|
|
|
|
|
|
/**
|
2015-02-12 12:13:19 +01:00
|
|
|
* The XMPPConnection interface provides an interface for connections to an XMPP server and
|
2014-04-15 11:22:46 +02:00
|
|
|
* implements shared methods which are used by the different types of connections (e.g.
|
2015-03-21 18:56:27 +01:00
|
|
|
* <code>XMPPTCPConnection</code> or <code>XMPPBOSHConnection</code>). To create a connection to an XMPP server
|
2014-04-15 11:22:46 +02:00
|
|
|
* a simple usage of this API might look like the following:
|
2010-02-09 12:55:56 +01:00
|
|
|
*
|
|
|
|
* <pre>
|
|
|
|
* // Create a connection to the igniterealtime.org XMPP server.
|
2015-02-11 17:36:46 +01:00
|
|
|
* XMPPTCPConnection 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.
|
2018-03-09 14:15:46 +01:00
|
|
|
* ChatManager chatManager = ChatManager.getInstanceFor(con);
|
|
|
|
* chatManager.addIncomingListener(new IncomingChatMessageListener() {
|
|
|
|
* public void newIncomingMessage(EntityBareJid from, Message message, Chat chat) {
|
2010-02-09 12:55:56 +01:00
|
|
|
* // Print out any messages we get back to standard out.
|
2017-12-23 20:21:19 +01:00
|
|
|
* System.out.println("Received message: " + message);
|
2010-02-09 12:55:56 +01:00
|
|
|
* }
|
|
|
|
* });
|
2018-03-09 14:15:46 +01:00
|
|
|
* Chat chat = chatManager.chatWith("jdoe@igniterealtime.org");
|
|
|
|
* chat.send("Howdy!");
|
2010-02-09 12:55:56 +01:00
|
|
|
* // Disconnect from the server
|
|
|
|
* con.disconnect();
|
|
|
|
* </pre>
|
2014-04-15 11:22:46 +02:00
|
|
|
* <p>
|
2015-02-12 12:09:52 +01:00
|
|
|
* Note that the XMPPConnection interface does intentionally not declare any methods that manipulate
|
|
|
|
* the connection state, e.g. <code>connect()</code>, <code>disconnect()</code>. You should use the
|
|
|
|
* most specific connection type, e.g. <code>XMPPTCPConnection</code> as declared type and use the
|
|
|
|
* XMPPConnection interface when you don't need to manipulate the connection state.
|
|
|
|
* </p>
|
|
|
|
* <p>
|
|
|
|
* XMPPConnections can be reused between connections. This means that an Connection may be connected,
|
|
|
|
* disconnected and then connected again. Listeners of the XMPPConnection will be retained across
|
2014-04-15 11:22:46 +02:00
|
|
|
* connections.
|
2015-02-12 12:09:52 +01:00
|
|
|
* </p>
|
|
|
|
*
|
2010-02-09 12:55:56 +01:00
|
|
|
* @author Matt Tucker
|
|
|
|
* @author Guenther Niess
|
|
|
|
*/
|
2014-05-25 12:28:08 +02:00
|
|
|
public interface XMPPConnection {
|
2010-02-09 12:55:56 +01:00
|
|
|
|
2015-05-18 16:48:23 +02:00
|
|
|
/**
|
|
|
|
* Returns the XMPP Domain of the service provided by the XMPP server and used for this connection. After
|
|
|
|
* authenticating with the server the returned value may be different.
|
|
|
|
*
|
|
|
|
* @return the XMPP domain of this XMPP session.
|
|
|
|
*/
|
2017-12-13 23:10:11 +01:00
|
|
|
DomainBareJid getXMPPServiceDomain();
|
2015-05-18 16:48:23 +02:00
|
|
|
|
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
|
|
|
*/
|
2017-12-13 23:10:11 +01:00
|
|
|
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
|
|
|
*/
|
2017-12-13 23:10:11 +01:00
|
|
|
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.
|
|
|
|
*/
|
2017-12-13 23:10:11 +01:00
|
|
|
EntityFullJid getUser();
|
2010-02-09 12:55:56 +01:00
|
|
|
|
|
|
|
/**
|
2015-01-28 17:14:33 +01:00
|
|
|
* Returns the stream ID for this connection, which is the value set by the server
|
2015-02-12 12:13:19 +01:00
|
|
|
* when opening an XMPP stream. This value will be <tt>null</tt> if not connected to the server.
|
2010-02-09 12:55:56 +01:00
|
|
|
*
|
|
|
|
* @return the ID of this connection returned from the XMPP server or <tt>null</tt> if
|
|
|
|
* not connected to the server.
|
2015-01-28 17:14:33 +01:00
|
|
|
* @see <a href="http://xmpp.org/rfcs/rfc6120.html#streams-attr-id">RFC 6120 § 4.7.3. id</a>
|
2010-02-09 12:55:56 +01:00
|
|
|
*/
|
2017-12-13 23:10:11 +01:00
|
|
|
String getStreamId();
|
2010-02-09 12:55:56 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns true if currently connected to the XMPP server.
|
|
|
|
*
|
|
|
|
* @return true if connected.
|
|
|
|
*/
|
2017-12-13 23:10:11 +01:00
|
|
|
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.
|
|
|
|
*/
|
2017-12-13 23:10:11 +01:00
|
|
|
boolean isAuthenticated();
|
2010-02-09 12:55:56 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns true if currently authenticated anonymously.
|
|
|
|
*
|
|
|
|
* @return true if authenticated anonymously.
|
|
|
|
*/
|
2017-12-13 23:10:11 +01:00
|
|
|
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.
|
|
|
|
*/
|
2017-12-13 23:10:11 +01:00
|
|
|
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.
|
|
|
|
*/
|
2017-12-13 23:10:11 +01:00
|
|
|
boolean isUsingCompression();
|
2010-02-09 12:55:56 +01:00
|
|
|
|
2015-03-04 21:44:43 +01:00
|
|
|
/**
|
|
|
|
* Sends the specified stanza to the server.
|
|
|
|
*
|
|
|
|
* @param stanza the stanza to send.
|
|
|
|
* @throws NotConnectedException if the connection is not connected.
|
2015-03-04 22:42:36 +01:00
|
|
|
* @throws InterruptedException
|
|
|
|
* */
|
2017-12-13 23:10:11 +01:00
|
|
|
void sendStanza(Stanza stanza) throws NotConnectedException, InterruptedException;
|
2015-03-04 21:44:43 +01:00
|
|
|
|
2014-09-11 09:49:16 +02:00
|
|
|
/**
|
2015-07-14 22:41:33 +02:00
|
|
|
* Send a Nonza.
|
2014-10-13 16:49:28 +02:00
|
|
|
* <p>
|
|
|
|
* <b>This method is not meant for end-user usage!</b> It allows sending plain stream elements, which should not be
|
|
|
|
* done by a user manually. <b>Doing so may result in a unstable or unusable connection.</b> Certain Smack APIs use
|
|
|
|
* this method to send plain stream elements.
|
|
|
|
* </p>
|
|
|
|
*
|
2015-07-14 22:41:33 +02:00
|
|
|
* @param nonza the Nonza to send.
|
2014-09-11 09:49:16 +02:00
|
|
|
* @throws NotConnectedException
|
2015-02-14 09:43:44 +01:00
|
|
|
* @throws InterruptedException
|
2014-09-11 09:49:16 +02:00
|
|
|
*/
|
2017-12-13 23:10:11 +01:00
|
|
|
void sendNonza(Nonza nonza) throws NotConnectedException, InterruptedException;
|
2014-09-11 09:49:16 +02:00
|
|
|
|
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.
|
|
|
|
*/
|
2017-12-13 23:10:11 +01:00
|
|
|
void addConnectionListener(ConnectionListener connectionListener);
|
2010-02-09 12:55:56 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Removes a connection listener from this connection.
|
|
|
|
*
|
|
|
|
* @param connectionListener a connection listener.
|
|
|
|
*/
|
2017-12-13 23:10:11 +01:00
|
|
|
void removeConnectionListener(ConnectionListener connectionListener);
|
2010-02-09 12:55:56 +01:00
|
|
|
|
2018-03-31 14:15:46 +02:00
|
|
|
/**
|
|
|
|
* Send an IQ request and wait for the response.
|
|
|
|
*
|
|
|
|
* @param request the IQ request
|
|
|
|
* @return an IQ with type 'result'
|
|
|
|
* @throws NoResponseException
|
|
|
|
* @throws XMPPErrorException
|
|
|
|
* @throws NotConnectedException
|
|
|
|
* @throws InterruptedException
|
|
|
|
* @since 4.3
|
|
|
|
*/
|
|
|
|
<I extends IQ> I sendIqRequestAndWaitForResponse(IQ request)
|
|
|
|
throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException;
|
|
|
|
|
2014-02-18 15:05:19 +01:00
|
|
|
/**
|
2018-04-23 21:06:35 +02:00
|
|
|
* Creates a new stanza collector collecting IQ responses that are replies to the IQ <code>request</code>.
|
|
|
|
* Does also send the <code>request</code> IQ. The stanza filter for the collector is an
|
2018-03-31 14:17:30 +02:00
|
|
|
* {@link IQReplyFilter}, guaranteeing that stanza id and JID in the 'from' address have
|
2014-02-23 21:08:35 +01:00
|
|
|
* expected values.
|
|
|
|
*
|
2018-04-23 21:06:35 +02:00
|
|
|
* @param request the IQ request to filter responses from
|
2018-03-31 14:17:30 +02:00
|
|
|
* @return a new stanza collector.
|
2014-03-19 14:22:20 +01:00
|
|
|
* @throws NotConnectedException
|
2015-02-14 09:43:44 +01:00
|
|
|
* @throws InterruptedException
|
2014-02-18 15:05:19 +01:00
|
|
|
*/
|
2018-04-23 21:06:35 +02:00
|
|
|
StanzaCollector createStanzaCollectorAndSend(IQ request) throws NotConnectedException, InterruptedException;
|
2014-02-18 15:05:19 +01:00
|
|
|
|
2010-02-09 12:55:56 +01:00
|
|
|
/**
|
2018-03-31 14:17:30 +02:00
|
|
|
* Creates a new stanza collector for this connection. A stanza filter determines
|
2018-04-23 21:06:35 +02:00
|
|
|
* which stanzas will be accumulated by the collector. A StanzaCollector is
|
2015-03-01 10:28:15 +01:00
|
|
|
* more suitable to use than a {@link StanzaListener} when you need to wait for
|
2010-02-09 12:55:56 +01:00
|
|
|
* a specific result.
|
|
|
|
*
|
2018-04-23 21:06:35 +02:00
|
|
|
* @param stanzaFilter the stanza filter to use.
|
|
|
|
* @param stanza the stanza to send right after the collector got created
|
2018-03-31 14:17:30 +02:00
|
|
|
* @return a new stanza collector.
|
2015-02-14 09:43:44 +01:00
|
|
|
* @throws InterruptedException
|
|
|
|
* @throws NotConnectedException
|
2014-10-13 10:45:00 +02:00
|
|
|
*/
|
2018-04-23 21:06:35 +02:00
|
|
|
StanzaCollector createStanzaCollectorAndSend(StanzaFilter stanzaFilter, Stanza stanza)
|
2015-02-14 09:43:44 +01:00
|
|
|
throws NotConnectedException, InterruptedException;
|
2014-10-13 10:45:00 +02:00
|
|
|
|
|
|
|
/**
|
2018-03-31 14:17:30 +02:00
|
|
|
* Creates a new stanza collector for this connection. A stanza filter
|
2018-04-23 21:06:35 +02:00
|
|
|
* determines which stanzas will be accumulated by the collector. A
|
2017-01-03 11:12:34 +01:00
|
|
|
* StanzaCollector is more suitable to use than a {@link StanzaListener}
|
2014-10-13 10:45:00 +02:00
|
|
|
* when you need to wait for a specific result.
|
|
|
|
* <p>
|
2018-04-23 21:06:35 +02:00
|
|
|
* <b>Note:</b> If you send a Stanza right after using this method, then
|
2014-10-13 10:45:00 +02:00
|
|
|
* consider using
|
2017-01-03 11:12:34 +01:00
|
|
|
* {@link #createStanzaCollectorAndSend(StanzaFilter, Stanza)} instead.
|
|
|
|
* Otherwise make sure cancel the StanzaCollector in every case, e.g. even
|
|
|
|
* if an exception is thrown, or otherwise you may leak the StanzaCollector.
|
2014-10-13 10:45:00 +02:00
|
|
|
* </p>
|
|
|
|
*
|
2018-04-23 21:06:35 +02:00
|
|
|
* @param stanzaFilter the stanza filter to use.
|
2018-03-31 14:17:30 +02:00
|
|
|
* @return a new stanza collector.
|
2010-02-09 12:55:56 +01:00
|
|
|
*/
|
2018-04-23 21:06:35 +02:00
|
|
|
StanzaCollector createStanzaCollector(StanzaFilter stanzaFilter);
|
2010-02-09 12:55:56 +01:00
|
|
|
|
2015-01-16 17:24:59 +01:00
|
|
|
/**
|
2018-03-31 14:17:30 +02:00
|
|
|
* Create a new stanza collector with the given stanza collector configuration.
|
2015-01-16 17:24:59 +01:00
|
|
|
* <p>
|
|
|
|
* Please make sure to cancel the collector when it is no longer required. See also
|
2017-01-03 11:12:34 +01:00
|
|
|
* {@link #createStanzaCollector(StanzaFilter)}.
|
2015-01-16 17:24:59 +01:00
|
|
|
* </p>
|
|
|
|
*
|
2018-03-31 14:17:30 +02:00
|
|
|
* @param configuration the stanza collector configuration.
|
|
|
|
* @return a new stanza collector.
|
2015-01-16 17:24:59 +01:00
|
|
|
* @since 4.1
|
|
|
|
*/
|
2017-12-13 23:10:11 +01:00
|
|
|
StanzaCollector createStanzaCollector(StanzaCollector.Configuration configuration);
|
2015-01-16 17:24:59 +01:00
|
|
|
|
2010-02-09 12:55:56 +01:00
|
|
|
/**
|
2018-03-31 14:17:30 +02:00
|
|
|
* Remove a stanza collector of this connection.
|
2010-02-09 12:55:56 +01:00
|
|
|
*
|
2018-03-31 14:17:30 +02:00
|
|
|
* @param collector a stanza collectors which was created for this connection.
|
2010-02-09 12:55:56 +01:00
|
|
|
*/
|
2017-12-13 23:10:11 +01:00
|
|
|
void removeStanzaCollector(StanzaCollector collector);
|
2010-02-09 12:55:56 +01:00
|
|
|
|
2015-01-05 21:42:35 +01:00
|
|
|
/**
|
2018-03-31 14:17:30 +02:00
|
|
|
* Registers a <b>synchronous</b> stanza listener with this connection. A stanza listener will be invoked only when
|
2018-04-23 21:06:35 +02:00
|
|
|
* an incoming stanza is received. A stanza filter determines which stanzas will be delivered to the listener. If
|
2018-03-31 14:17:30 +02:00
|
|
|
* the same stanza listener is added again with a different filter, only the new filter will be used.
|
2015-01-05 21:42:35 +01:00
|
|
|
* <p>
|
2018-03-31 14:17:30 +02:00
|
|
|
* <b>Important:</b> This stanza listeners will be called in the same <i>single</i> thread that processes all
|
|
|
|
* incoming stanzas. Only use this kind of stanza filter if it does not perform any XMPP activity that waits for a
|
2015-03-01 10:28:15 +01:00
|
|
|
* response. Consider using {@link #addAsyncStanzaListener(StanzaListener, StanzaFilter)} when possible, i.e. when
|
2018-04-23 21:06:35 +02:00
|
|
|
* the invocation order doesn't have to be the same as the order of the arriving stanzas. If the order of the
|
|
|
|
* arriving stanzas, consider using a {@link StanzaCollector} when possible.
|
2015-01-05 21:42:35 +01:00
|
|
|
* </p>
|
|
|
|
*
|
2018-04-23 21:06:35 +02:00
|
|
|
* @param stanzaListener the stanza listener to notify of new received stanzas.
|
|
|
|
* @param stanzaFilter the stanza filter to use.
|
2018-02-28 15:02:55 +01:00
|
|
|
* @see #addStanzaInterceptor(StanzaListener, StanzaFilter)
|
2015-01-05 21:42:35 +01:00
|
|
|
* @since 4.1
|
|
|
|
*/
|
2018-04-23 21:06:35 +02:00
|
|
|
void addSyncStanzaListener(StanzaListener stanzaListener, StanzaFilter stanzaFilter);
|
2015-01-05 21:42:35 +01:00
|
|
|
|
|
|
|
/**
|
2018-04-23 21:06:35 +02:00
|
|
|
* Removes a stanza listener for received stanzas from this connection.
|
2015-01-05 21:42:35 +01:00
|
|
|
*
|
2018-04-23 21:06:35 +02:00
|
|
|
* @param stanzaListener the stanza listener to remove.
|
2018-03-31 14:17:30 +02:00
|
|
|
* @return true if the stanza listener was removed
|
2015-01-05 21:42:35 +01:00
|
|
|
* @since 4.1
|
|
|
|
*/
|
2018-04-23 21:06:35 +02:00
|
|
|
boolean removeSyncStanzaListener(StanzaListener stanzaListener);
|
2015-01-05 21:42:35 +01:00
|
|
|
|
2014-12-30 20:45:15 +01:00
|
|
|
/**
|
2018-03-31 14:17:30 +02:00
|
|
|
* Registers an <b>asynchronous</b> stanza listener with this connection. A stanza listener will be invoked only
|
2018-04-23 21:06:35 +02:00
|
|
|
* when an incoming stanza is received. A stanza filter determines which stanzas will be delivered to the listener.
|
2018-03-31 14:17:30 +02:00
|
|
|
* If the same stanza listener is added again with a different filter, only the new filter will be used.
|
2014-12-30 20:45:15 +01:00
|
|
|
* <p>
|
2018-03-31 14:17:30 +02:00
|
|
|
* Unlike {@link #addAsyncStanzaListener(StanzaListener, StanzaFilter)} stanza listeners added with this method will be
|
|
|
|
* invoked asynchronously in their own thread. Use this method if the order of the stanza listeners must not depend
|
2014-12-30 20:45:15 +01:00
|
|
|
* on the order how the stanzas where received.
|
|
|
|
* </p>
|
|
|
|
*
|
2018-04-23 21:06:35 +02:00
|
|
|
* @param stanzaListener the stanza listener to notify of new received stanzas.
|
|
|
|
* @param stanzaFilter the stanza filter to use.
|
2018-02-28 15:02:55 +01:00
|
|
|
* @see #addStanzaInterceptor(StanzaListener, StanzaFilter)
|
2015-01-05 21:42:35 +01:00
|
|
|
* @since 4.1
|
|
|
|
*/
|
2018-04-23 21:06:35 +02:00
|
|
|
void addAsyncStanzaListener(StanzaListener stanzaListener, StanzaFilter stanzaFilter);
|
2014-12-30 20:45:15 +01:00
|
|
|
|
|
|
|
/**
|
2018-04-23 21:06:35 +02:00
|
|
|
* Removes an <b>asynchronous</b> stanza listener for received stanzas from this connection.
|
2014-12-30 20:45:15 +01:00
|
|
|
*
|
2018-04-23 21:06:35 +02:00
|
|
|
* @param stanzaListener the stanza listener to remove.
|
2018-03-31 14:17:30 +02:00
|
|
|
* @return true if the stanza listener was removed
|
2015-01-05 21:42:35 +01:00
|
|
|
* @since 4.1
|
2014-12-30 20:45:15 +01:00
|
|
|
*/
|
2018-04-23 21:06:35 +02:00
|
|
|
boolean removeAsyncStanzaListener(StanzaListener stanzaListener);
|
2014-12-30 20:45:15 +01:00
|
|
|
|
2010-02-09 12:55:56 +01:00
|
|
|
/**
|
2018-03-31 14:17:30 +02:00
|
|
|
* Registers a stanza listener with this connection. The listener will be
|
|
|
|
* notified of every stanza that this connection sends. A stanza filter determines
|
2018-04-23 21:06:35 +02:00
|
|
|
* which stanzas will be delivered to the listener. Note that the thread
|
|
|
|
* that writes stanzas will be used to invoke the listeners. Therefore, each
|
2018-03-31 14:17:30 +02:00
|
|
|
* stanza listener should complete all operations quickly or use a different
|
2010-02-09 12:55:56 +01:00
|
|
|
* thread for processing.
|
|
|
|
*
|
2018-04-23 21:06:35 +02:00
|
|
|
* @param stanzaListener the stanza listener to notify of sent stanzas.
|
|
|
|
* @param stanzaFilter the stanza filter to use.
|
2018-02-28 15:02:55 +01:00
|
|
|
* @deprecated use {@link #addStanzaSendingListener} instead
|
2010-02-09 12:55:56 +01:00
|
|
|
*/
|
2018-02-28 15:02:55 +01:00
|
|
|
// TODO Remove in Smack 4.4
|
|
|
|
@Deprecated
|
2018-04-23 21:06:35 +02:00
|
|
|
void addPacketSendingListener(StanzaListener stanzaListener, StanzaFilter stanzaFilter);
|
2010-02-09 12:55:56 +01:00
|
|
|
|
2018-02-28 15:02:55 +01:00
|
|
|
/**
|
2018-03-31 14:17:30 +02:00
|
|
|
* Registers a stanza listener with this connection. The listener will be
|
|
|
|
* notified of every stanza that this connection sends. A stanza filter determines
|
2018-04-23 21:06:35 +02:00
|
|
|
* which stanzas will be delivered to the listener. Note that the thread
|
|
|
|
* that writes stanzas will be used to invoke the listeners. Therefore, each
|
2018-03-31 14:17:30 +02:00
|
|
|
* stanza listener should complete all operations quickly or use a different
|
2018-02-28 15:02:55 +01:00
|
|
|
* thread for processing.
|
|
|
|
*
|
2018-04-23 21:06:35 +02:00
|
|
|
* @param stanzaListener the stanza listener to notify of sent stanzas.
|
|
|
|
* @param stanzaFilter the stanza filter to use.
|
2018-02-28 15:02:55 +01:00
|
|
|
*/
|
2018-04-23 21:06:35 +02:00
|
|
|
void addStanzaSendingListener(StanzaListener stanzaListener, StanzaFilter stanzaFilter);
|
2018-02-28 15:02:55 +01:00
|
|
|
|
2010-02-09 12:55:56 +01:00
|
|
|
/**
|
2018-04-23 21:06:35 +02:00
|
|
|
* Removes a stanza listener for sending stanzas from this connection.
|
2010-02-09 12:55:56 +01:00
|
|
|
*
|
2018-04-23 21:06:35 +02:00
|
|
|
* @param stanzaListener the stanza listener to remove.
|
2018-02-28 15:02:55 +01:00
|
|
|
* @deprecated use {@link #removeStanzaSendingListener} instead
|
2010-02-09 12:55:56 +01:00
|
|
|
*/
|
2018-02-28 15:02:55 +01:00
|
|
|
// TODO Remove in Smack 4.4
|
|
|
|
@Deprecated
|
2018-04-23 21:06:35 +02:00
|
|
|
void removePacketSendingListener(StanzaListener stanzaListener);
|
2010-02-09 12:55:56 +01:00
|
|
|
|
2018-02-28 15:02:55 +01:00
|
|
|
/**
|
2018-04-23 21:06:35 +02:00
|
|
|
* Removes a stanza listener for sending stanzas from this connection.
|
2018-02-28 15:02:55 +01:00
|
|
|
*
|
2018-04-23 21:06:35 +02:00
|
|
|
* @param stanzaListener the stanza listener to remove.
|
2018-02-28 15:02:55 +01:00
|
|
|
*/
|
2018-04-23 21:06:35 +02:00
|
|
|
void removeStanzaSendingListener(StanzaListener stanzaListener);
|
2018-02-28 15:02:55 +01:00
|
|
|
|
2010-02-09 12:55:56 +01:00
|
|
|
/**
|
2018-03-31 14:17:30 +02:00
|
|
|
* Registers a stanza interceptor with this connection. The interceptor will be
|
|
|
|
* invoked every time a stanza is about to be sent by this connection. Interceptors
|
2018-04-23 21:06:35 +02:00
|
|
|
* may modify the stanza to be sent. A stanza filter determines which stanzas
|
2010-02-09 12:55:56 +01:00
|
|
|
* will be delivered to the interceptor.
|
2014-01-20 03:52:44 +01:00
|
|
|
*
|
|
|
|
* <p>
|
2018-04-23 21:06:35 +02:00
|
|
|
* NOTE: For a similar functionality on incoming stanzas, see {@link #addAsyncStanzaListener(StanzaListener, StanzaFilter)}.
|
2018-02-28 15:02:55 +01:00
|
|
|
* </p>
|
2010-02-09 12:55:56 +01:00
|
|
|
*
|
2018-04-23 21:06:35 +02:00
|
|
|
* @param stanzaInterceptor the stanza interceptor to notify of stanzas about to be sent.
|
|
|
|
* @param stanzaFilter the stanza filter to use.
|
2018-02-28 15:02:55 +01:00
|
|
|
* @deprecated use {@link #addStanzaInterceptor} instead
|
2010-02-09 12:55:56 +01:00
|
|
|
*/
|
2018-02-28 15:02:55 +01:00
|
|
|
// TODO Remove in Smack 4.4
|
|
|
|
@Deprecated
|
2018-04-23 21:06:35 +02:00
|
|
|
void addPacketInterceptor(StanzaListener stanzaInterceptor, StanzaFilter stanzaFilter);
|
2015-03-17 11:33:02 +01:00
|
|
|
|
2018-02-28 15:02:55 +01:00
|
|
|
/**
|
2018-03-31 14:17:30 +02:00
|
|
|
* Registers a stanza interceptor with this connection. The interceptor will be
|
|
|
|
* invoked every time a stanza is about to be sent by this connection. Interceptors
|
2018-04-23 21:06:35 +02:00
|
|
|
* may modify the stanza to be sent. A stanza filter determines which stanzas
|
2018-02-28 15:02:55 +01:00
|
|
|
* will be delivered to the interceptor.
|
|
|
|
*
|
|
|
|
* <p>
|
2018-04-23 21:06:35 +02:00
|
|
|
* NOTE: For a similar functionality on incoming stanzas, see {@link #addAsyncStanzaListener(StanzaListener, StanzaFilter)}.
|
2018-02-28 15:02:55 +01:00
|
|
|
* </p>
|
|
|
|
*
|
2018-04-23 21:06:35 +02:00
|
|
|
* @param stanzaInterceptor the stanza interceptor to notify of stanzas about to be sent.
|
|
|
|
* @param stanzaFilter the stanza filter to use.
|
2018-02-28 15:02:55 +01:00
|
|
|
*/
|
2018-04-23 21:06:35 +02:00
|
|
|
void addStanzaInterceptor(StanzaListener stanzaInterceptor, StanzaFilter stanzaFilter);
|
2018-02-28 15:02:55 +01:00
|
|
|
|
2010-02-09 12:55:56 +01:00
|
|
|
/**
|
2018-03-31 14:17:30 +02:00
|
|
|
* Removes a stanza interceptor.
|
2010-02-09 12:55:56 +01:00
|
|
|
*
|
2018-04-23 21:06:35 +02:00
|
|
|
* @param stanzaInterceptor the stanza interceptor to remove.
|
2018-02-28 15:02:55 +01:00
|
|
|
* @deprecated user {@link #removeStanzaInterceptor} instead
|
2010-02-09 12:55:56 +01:00
|
|
|
*/
|
2018-02-28 15:02:55 +01:00
|
|
|
// TODO Remove in Smack 4.4
|
|
|
|
@Deprecated
|
2018-04-23 21:06:35 +02:00
|
|
|
void removePacketInterceptor(StanzaListener stanzaInterceptor);
|
2010-02-09 12:55:56 +01:00
|
|
|
|
2018-02-28 15:02:55 +01:00
|
|
|
/**
|
2018-03-31 14:17:30 +02:00
|
|
|
* Removes a stanza interceptor.
|
2018-02-28 15:02:55 +01:00
|
|
|
*
|
2018-04-23 21:06:35 +02:00
|
|
|
* @param stanzaInterceptor the stanza interceptor to remove.
|
2018-02-28 15:02:55 +01:00
|
|
|
*/
|
2018-04-23 21:06:35 +02:00
|
|
|
void removeStanzaInterceptor(StanzaListener stanzaInterceptor);
|
2014-03-15 11:39:38 +01:00
|
|
|
|
2014-04-03 10:50:23 +02:00
|
|
|
/**
|
|
|
|
* Returns the current value of the reply timeout in milliseconds for request for this
|
2017-01-12 20:57:19 +01:00
|
|
|
* XMPPConnection instance.
|
|
|
|
*
|
|
|
|
* @return the reply timeout in milliseconds
|
|
|
|
*/
|
2017-12-13 23:10:11 +01:00
|
|
|
long getReplyTimeout();
|
2017-01-12 20:57:19 +01:00
|
|
|
|
|
|
|
/**
|
2018-03-31 14:17:30 +02:00
|
|
|
* Set the stanza reply timeout in milliseconds. In most cases, Smack will throw a
|
2017-01-12 20:57:19 +01:00
|
|
|
* {@link NoResponseException} if no reply to a request was received within the timeout period.
|
|
|
|
*
|
|
|
|
* @param timeout for a reply in milliseconds
|
|
|
|
*/
|
2017-12-13 23:10:11 +01:00
|
|
|
void setReplyTimeout(long timeout);
|
2017-01-12 20:57:19 +01:00
|
|
|
|
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
|
|
|
|
*/
|
2017-12-13 23:10:11 +01:00
|
|
|
int getConnectionCounter();
|
2014-04-14 09:07:42 +02:00
|
|
|
|
2017-12-13 23:10:11 +01:00
|
|
|
enum FromMode {
|
2014-04-14 09:07:42 +02:00
|
|
|
/**
|
2017-12-25 12:09:46 +01:00
|
|
|
* Leave the 'from' attribute unchanged. This is the behavior of Smack < 4.0
|
2014-04-14 09:07:42 +02:00
|
|
|
*/
|
|
|
|
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
|
|
|
|
*/
|
2017-12-13 23:10:11 +01:00
|
|
|
void setFromMode(FromMode fromMode);
|
2014-04-14 09:07:42 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the currently active FromMode.
|
|
|
|
*
|
|
|
|
* @return the currently active {@link FromMode}
|
|
|
|
*/
|
2017-12-13 23:10:11 +01:00
|
|
|
FromMode getFromMode();
|
2014-06-05 03:27:16 +02:00
|
|
|
|
2014-09-11 09:49:16 +02:00
|
|
|
/**
|
2018-03-31 14:17:30 +02:00
|
|
|
* Get the feature stanza extensions for a given stream feature of the
|
2014-09-11 09:49:16 +02:00
|
|
|
* server, or <code>null</code> if the server doesn't support that feature.
|
2017-12-23 20:21:19 +01:00
|
|
|
*
|
|
|
|
* @param <F> {@link ExtensionElement} type of the feature.
|
2014-09-11 09:49:16 +02:00
|
|
|
* @param element
|
|
|
|
* @param namespace
|
2018-03-31 14:17:30 +02:00
|
|
|
* @return a stanza extensions of the feature or <code>null</code>
|
2014-09-11 09:49:16 +02:00
|
|
|
*/
|
2017-12-13 23:10:11 +01:00
|
|
|
<F extends ExtensionElement> F getFeature(String element, String namespace);
|
2014-09-11 09:49:16 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Return true if the server supports the given stream feature.
|
|
|
|
*
|
|
|
|
* @param element
|
|
|
|
* @param namespace
|
2014-11-02 12:12:56 +01:00
|
|
|
* @return true if the server supports the stream feature.
|
2014-09-11 09:49:16 +02:00
|
|
|
*/
|
2017-12-13 23:10:11 +01:00
|
|
|
boolean hasFeature(String element, String namespace);
|
2014-09-11 09:49:16 +02:00
|
|
|
|
2017-08-12 17:35:20 +02:00
|
|
|
/**
|
|
|
|
* Send an IQ request asynchronously. The connection's default reply timeout will be used.
|
|
|
|
*
|
|
|
|
* @param request the IQ request to send.
|
|
|
|
* @return a SmackFuture for the response.
|
|
|
|
*/
|
2017-12-13 23:10:11 +01:00
|
|
|
SmackFuture<IQ, Exception> sendIqRequestAsync(IQ request);
|
2017-08-12 17:35:20 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Send an IQ request asynchronously.
|
|
|
|
*
|
|
|
|
* @param request the IQ request to send.
|
|
|
|
* @param timeout the reply timeout in milliseconds.
|
|
|
|
* @return a SmackFuture for the response.
|
|
|
|
*/
|
2017-12-13 23:10:11 +01:00
|
|
|
SmackFuture<IQ, Exception> sendIqRequestAsync(IQ request, long timeout);
|
2017-08-12 17:35:20 +02:00
|
|
|
|
|
|
|
/**
|
2017-08-16 13:46:42 +02:00
|
|
|
* Send a stanza asynchronously, waiting for exactly one response stanza using the given reply filter. The
|
|
|
|
* connection's default reply timeout will be used.
|
2017-08-12 17:35:20 +02:00
|
|
|
*
|
|
|
|
* @param stanza the stanza to send.
|
|
|
|
* @param replyFilter the filter used for the response stanza.
|
|
|
|
* @return a SmackFuture for the response.
|
|
|
|
*/
|
2017-12-13 23:10:11 +01:00
|
|
|
<S extends Stanza> SmackFuture<S, Exception> sendAsync(S stanza, StanzaFilter replyFilter);
|
2017-08-12 17:35:20 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Send a stanza asynchronously, waiting for exactly one response stanza using the given reply filter.
|
|
|
|
*
|
|
|
|
* @param stanza the stanza to send.
|
|
|
|
* @param replyFilter the filter used for the response stanza.
|
|
|
|
* @param timeout the reply timeout in milliseconds.
|
|
|
|
* @return a SmackFuture for the response.
|
|
|
|
*/
|
2017-12-13 23:10:11 +01:00
|
|
|
<S extends Stanza> SmackFuture<S, Exception> sendAsync(S stanza, StanzaFilter replyFilter, long timeout);
|
2017-08-12 17:35:20 +02:00
|
|
|
|
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
|
2017-08-16 13:46:42 +02:00
|
|
|
* @throws InterruptedException
|
|
|
|
* @deprecated use {@link #sendAsync(Stanza, StanzaFilter)} instead.
|
2014-08-16 00:04:24 +02:00
|
|
|
*/
|
2017-08-16 13:46:42 +02:00
|
|
|
@Deprecated
|
|
|
|
// TODO: Remove in Smack 4.4.
|
2017-12-13 23:10:11 +01:00
|
|
|
void sendStanzaWithResponseCallback(Stanza stanza, StanzaFilter replyFilter,
|
2015-03-04 22:42:36 +01:00
|
|
|
StanzaListener callback) throws NotConnectedException, InterruptedException;
|
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. 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
|
2015-02-14 09:43:44 +01:00
|
|
|
* @throws InterruptedException
|
2017-08-16 13:46:42 +02:00
|
|
|
* @deprecated use {@link #sendAsync(Stanza, StanzaFilter)} instead.
|
2014-08-16 00:04:24 +02:00
|
|
|
*/
|
2017-08-16 13:46:42 +02:00
|
|
|
@Deprecated
|
|
|
|
// TODO: Remove in Smack 4.4.
|
2017-12-13 23:10:11 +01:00
|
|
|
void sendStanzaWithResponseCallback(Stanza stanza, StanzaFilter replyFilter, StanzaListener callback,
|
2017-08-16 13:46:42 +02:00
|
|
|
@SuppressWarnings("deprecation") ExceptionCallback exceptionCallback) throws NotConnectedException, InterruptedException;
|
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. 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
|
2015-02-14 09:43:44 +01:00
|
|
|
* @throws InterruptedException
|
2017-08-16 13:46:42 +02:00
|
|
|
* @deprecated use {@link #sendAsync(Stanza, StanzaFilter, long)} instead.
|
2014-08-16 00:04:24 +02:00
|
|
|
*/
|
2017-08-16 13:46:42 +02:00
|
|
|
@Deprecated
|
|
|
|
// TODO: Remove in Smack 4.4.
|
2017-12-13 23:10:11 +01:00
|
|
|
void sendStanzaWithResponseCallback(Stanza stanza, StanzaFilter replyFilter,
|
2018-03-28 14:02:21 +02:00
|
|
|
StanzaListener callback, @SuppressWarnings("deprecation") ExceptionCallback exceptionCallback,
|
2015-02-14 09:43:44 +01:00
|
|
|
long timeout) throws NotConnectedException, InterruptedException;
|
2014-08-16 00:04:24 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* 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
|
2015-02-14 09:43:44 +01:00
|
|
|
* @throws InterruptedException
|
2017-08-16 13:46:42 +02:00
|
|
|
* @deprecated use {@link #sendIqRequestAsync(IQ)} instead.
|
2014-08-16 00:04:24 +02:00
|
|
|
*/
|
2017-08-16 13:46:42 +02:00
|
|
|
@Deprecated
|
|
|
|
// TODO: Remove in Smack 4.4.
|
2017-12-13 23:10:11 +01:00
|
|
|
void sendIqWithResponseCallback(IQ iqRequest, StanzaListener callback) throws NotConnectedException, InterruptedException;
|
2014-08-16 00:04:24 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* 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
|
2015-02-14 09:43:44 +01:00
|
|
|
* @throws InterruptedException
|
2017-08-16 13:46:42 +02:00
|
|
|
* @deprecated use {@link #sendIqRequestAsync(IQ)} instead.
|
2014-08-16 00:04:24 +02:00
|
|
|
*/
|
2017-08-16 13:46:42 +02:00
|
|
|
@Deprecated
|
|
|
|
// TODO: Remove in Smack 4.4.
|
2017-12-13 23:10:11 +01:00
|
|
|
void sendIqWithResponseCallback(IQ iqRequest, StanzaListener callback,
|
2017-08-16 13:46:42 +02:00
|
|
|
@SuppressWarnings("deprecation") ExceptionCallback exceptionCallback) throws NotConnectedException, InterruptedException;
|
2014-08-16 00:04:24 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* 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
|
2015-02-14 09:43:44 +01:00
|
|
|
* @throws InterruptedException
|
2017-08-16 13:46:42 +02:00
|
|
|
* @deprecated use {@link #sendIqRequestAsync(IQ, long)} instead.
|
2014-08-16 00:04:24 +02:00
|
|
|
*/
|
2017-08-16 13:46:42 +02:00
|
|
|
@Deprecated
|
|
|
|
// TODO: Remove in Smack 4.4.
|
2018-03-28 14:02:21 +02:00
|
|
|
void sendIqWithResponseCallback(IQ iqRequest, StanzaListener callback,
|
|
|
|
@SuppressWarnings("deprecation") ExceptionCallback exceptionCallback, long timeout)
|
2015-02-14 09:43:44 +01:00
|
|
|
throws NotConnectedException, InterruptedException;
|
2014-08-20 10:33:52 +02:00
|
|
|
|
2015-01-07 19:35:11 +01:00
|
|
|
/**
|
|
|
|
* Add a callback that is called exactly once and synchronously with the incoming stanza that matches the given
|
2018-03-31 14:17:30 +02:00
|
|
|
* stanza filter.
|
2015-01-07 19:35:11 +01:00
|
|
|
*
|
2018-03-31 14:17:30 +02:00
|
|
|
* @param callback the callback invoked once the stanza filter matches a stanza.
|
2018-04-23 21:06:35 +02:00
|
|
|
* @param stanzaFilter the filter to match stanzas or null to match all.
|
2015-01-07 19:35:11 +01:00
|
|
|
*/
|
2018-04-23 21:06:35 +02:00
|
|
|
void addOneTimeSyncCallback(StanzaListener callback, StanzaFilter stanzaFilter);
|
2015-01-07 19:35:11 +01:00
|
|
|
|
2015-01-08 11:01:35 +01:00
|
|
|
/**
|
|
|
|
* Register an IQ request handler with this connection.
|
|
|
|
* <p>
|
|
|
|
* IQ request handler process incoming IQ requests, i.e. incoming IQ stanzas of type 'get' or 'set', and return a result.
|
|
|
|
* </p>
|
|
|
|
* @param iqRequestHandler the IQ request handler to register.
|
|
|
|
* @return the previously registered IQ request handler or null.
|
|
|
|
*/
|
2017-12-13 23:10:11 +01:00
|
|
|
IQRequestHandler registerIQRequestHandler(IQRequestHandler iqRequestHandler);
|
2015-01-08 11:01:35 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Convenience method for {@link #unregisterIQRequestHandler(String, String, org.jivesoftware.smack.packet.IQ.Type)}.
|
|
|
|
*
|
|
|
|
* @param iqRequestHandler
|
|
|
|
* @return the previously registered IQ request handler or null.
|
|
|
|
*/
|
2017-12-13 23:10:11 +01:00
|
|
|
IQRequestHandler unregisterIQRequestHandler(IQRequestHandler iqRequestHandler);
|
2015-01-08 11:01:35 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Unregister an IQ request handler with this connection.
|
|
|
|
*
|
|
|
|
* @param element the IQ element the IQ request handler is responsible for.
|
|
|
|
* @param namespace the IQ namespace the IQ request handler is responsible for.
|
|
|
|
* @param type the IQ type the IQ request handler is responsible for.
|
|
|
|
* @return the previously registered IQ request handler or null.
|
|
|
|
*/
|
2017-12-13 23:10:11 +01:00
|
|
|
IQRequestHandler unregisterIQRequestHandler(String element, String namespace, IQ.Type type);
|
2015-01-08 11:01:35 +01:00
|
|
|
|
2014-08-20 10:33:52 +02:00
|
|
|
/**
|
|
|
|
* Returns the timestamp in milliseconds when the last stanza was received.
|
|
|
|
*
|
|
|
|
* @return the timestamp in milliseconds
|
|
|
|
*/
|
2017-12-13 23:10:11 +01:00
|
|
|
long getLastStanzaReceived();
|
2014-09-11 09:49:16 +02:00
|
|
|
|
2010-02-09 12:55:56 +01:00
|
|
|
}
|