xmppconnection.html

来自「开源项目smack的API文件」· HTML 代码 · 共 1,263 行 · 第 1/5 页

HTML
1,263 行
字号
<DD>Logs in to the server anonymously. Very few servers are configured to support anonymous authentication, so it's fairly likely logging in anonymously will fail. If anonymous login does succeed, your XMPP address will likely be in the form "server/123ABC" (where "123ABC" is a random value generated by the server).<P><DD><DL><DT><B>Throws:</B><DD><CODE><A HREF="../../../org/jivesoftware/smack/XMPPException.html" title="class in org.jivesoftware.smack">XMPPException</A></CODE> - if an error occurs or anonymous logins are not supported by the server.<DD><CODE><A HREF="http://java.sun.com/j2se/1.3/docs/api/java/lang/IllegalStateException.html" title="class or interface in java.lang">IllegalStateException</A></CODE> - if not connected to the server, or already logged in                               to the serrver.</DL></DD></DL><HR><A NAME="getRoster()"><!-- --></A><H3>getRoster</H3><PRE>public <A HREF="../../../org/jivesoftware/smack/Roster.html" title="class in org.jivesoftware.smack">Roster</A> <B>getRoster</B>()</PRE><DL><DD>Returns the roster for the user logged into the server. If the user has not yet logged into the server (or if the user is logged in anonymously), this method will return <tt>null</tt>.<P><DD><DL><DT><B>Returns:</B><DD>the user's roster, or <tt>null</tt> if the user has not logged in yet.</DL></DD></DL><HR><A NAME="getAccountManager()"><!-- --></A><H3>getAccountManager</H3><PRE>public <A HREF="../../../org/jivesoftware/smack/AccountManager.html" title="class in org.jivesoftware.smack">AccountManager</A> <B>getAccountManager</B>()</PRE><DL><DD>Returns an account manager instance for this connection.<P><DD><DL><DT><B>Returns:</B><DD>an account manager for this connection.</DL></DD></DL><HR><A NAME="getChatManager()"><!-- --></A><H3>getChatManager</H3><PRE>public <A HREF="../../../org/jivesoftware/smack/ChatManager.html" title="class in org.jivesoftware.smack">ChatManager</A> <B>getChatManager</B>()</PRE><DL><DD>Returns a chat manager instance for this connection. The ChatManager manages all incoming and outgoing chats on the current connection.<P><DD><DL><DT><B>Returns:</B><DD>a chat manager instance for this connection.</DL></DD></DL><HR><A NAME="isConnected()"><!-- --></A><H3>isConnected</H3><PRE>public boolean <B>isConnected</B>()</PRE><DL><DD>Returns true if currently connected to the XMPP server.<P><DD><DL><DT><B>Returns:</B><DD>true if connected.</DL></DD></DL><HR><A NAME="isSecureConnection()"><!-- --></A><H3>isSecureConnection</H3><PRE>public boolean <B>isSecureConnection</B>()</PRE><DL><DD>Returns true if the connection is a secured one, such as an SSL connection or if TLS was negotiated successfully.<P><DD><DL><DT><B>Returns:</B><DD>true if a secure connection to the server.</DL></DD></DL><HR><A NAME="isAuthenticated()"><!-- --></A><H3>isAuthenticated</H3><PRE>public boolean <B>isAuthenticated</B>()</PRE><DL><DD>Returns true if currently authenticated by successfully calling the login method.<P><DD><DL><DT><B>Returns:</B><DD>true if authenticated.</DL></DD></DL><HR><A NAME="isAnonymous()"><!-- --></A><H3>isAnonymous</H3><PRE>public boolean <B>isAnonymous</B>()</PRE><DL><DD>Returns true if currently authenticated anonymously.<P><DD><DL><DT><B>Returns:</B><DD>true if authenticated anonymously.</DL></DD></DL><HR><A NAME="shutdown(org.jivesoftware.smack.packet.Presence)"><!-- --></A><H3>shutdown</H3><PRE>protected void <B>shutdown</B>(<A HREF="../../../org/jivesoftware/smack/packet/Presence.html" title="class in org.jivesoftware.smack.packet">Presence</A>&nbsp;unavailablePresence)</PRE><DL><DD>Closes the connection by setting presence to unavailable then closing the stream to the XMPP server. The shutdown logic will be used during a planned disconnection or when dealing with an unexpected disconnection. Unlike <A HREF="../../../org/jivesoftware/smack/XMPPConnection.html#disconnect()"><CODE>disconnect()</CODE></A> the connection's packet reader, packet writer, and <A HREF="../../../org/jivesoftware/smack/Roster.html" title="class in org.jivesoftware.smack"><CODE>Roster</CODE></A> will not be removed; thus connection's state is kept.<P><DD><DL><DT><B>Parameters:</B><DD><CODE>unavailablePresence</CODE> - the presence packet to send during shutdown.</DL></DD></DL><HR><A NAME="disconnect()"><!-- --></A><H3>disconnect</H3><PRE>public void <B>disconnect</B>()</PRE><DL><DD>Closes the connection by setting presence to unavailable then closing the stream to 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, listeners and other stateful objects cannot be re-used by simply calling connect() on this connection again. This is unlike the behavior during unexpected disconnects (and subsequent connections). In that case, all state is preserved to allow for more seamless error recovery.<P><DD><DL></DL></DD></DL><HR><A NAME="disconnect(org.jivesoftware.smack.packet.Presence)"><!-- --></A><H3>disconnect</H3><PRE>public void <B>disconnect</B>(<A HREF="../../../org/jivesoftware/smack/packet/Presence.html" title="class in org.jivesoftware.smack.packet">Presence</A>&nbsp;unavailablePresence)</PRE><DL><DD>Closes the connection. A custom unavailable presence is sent to the server, followed 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 presence packet with whatever data is set.<p> <p/> This method cleans up all resources used by the connection. Therefore, the roster, listeners and other stateful objects cannot be re-used by simply calling connect() on this connection again. This is unlike the behavior during unexpected disconnects (and subsequent connections). In that case, all state is preserved to allow for more seamless error recovery.<P><DD><DL><DT><B>Parameters:</B><DD><CODE>unavailablePresence</CODE> - the presence packet to send during shutdown.</DL></DD></DL><HR><A NAME="sendPacket(org.jivesoftware.smack.packet.Packet)"><!-- --></A><H3>sendPacket</H3><PRE>public void <B>sendPacket</B>(<A HREF="../../../org/jivesoftware/smack/packet/Packet.html" title="class in org.jivesoftware.smack.packet">Packet</A>&nbsp;packet)</PRE><DL><DD>Sends the specified packet to the server.<P><DD><DL><DT><B>Parameters:</B><DD><CODE>packet</CODE> - the packet to send.</DL></DD></DL><HR><A NAME="addPacketListener(org.jivesoftware.smack.PacketListener, org.jivesoftware.smack.filter.PacketFilter)"><!-- --></A><H3>addPacketListener</H3><PRE>public void <B>addPacketListener</B>(<A HREF="../../../org/jivesoftware/smack/PacketListener.html" title="interface in org.jivesoftware.smack">PacketListener</A>&nbsp;packetListener,                              <A HREF="../../../org/jivesoftware/smack/filter/PacketFilter.html" title="interface in org.jivesoftware.smack.filter">PacketFilter</A>&nbsp;packetFilter)</PRE><DL><DD>Registers a packet listener with this connection. A packet filter determines 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.<P><DD><DL><DT><B>Parameters:</B><DD><CODE>packetListener</CODE> - the packet listener to notify of new packets.<DD><CODE>packetFilter</CODE> - the packet filter to use.</DL></DD></DL><HR><A NAME="removePacketListener(org.jivesoftware.smack.PacketListener)"><!-- --></A><H3>removePacketListener</H3><PRE>public void <B>removePacketListener</B>(<A HREF="../../../org/jivesoftware/smack/PacketListener.html" title="interface in org.jivesoftware.smack">PacketListener</A>&nbsp;packetListener)</PRE><DL><DD>Removes a packet listener from this connection.<P><DD><DL><DT><B>Parameters:</B><DD><CODE>packetListener</CODE> - the packet listener to remove.</DL></DD></DL><HR><A NAME="addPacketWriterListener(org.jivesoftware.smack.PacketListener, org.jivesoftware.smack.filter.PacketFilter)"><!-- --></A><H3>addPacketWriterListener</H3><PRE>public void <B>addPacketWriterListener</B>(<A HREF="../../../org/jivesoftware/smack/PacketListener.html" title="interface in org.jivesoftware.smack">PacketListener</A>&nbsp;packetListener,                                    <A HREF="../../../org/jivesoftware/smack/filter/PacketFilter.html" title="interface in org.jivesoftware.smack.filter">PacketFilter</A>&nbsp;packetFilter)</PRE><DL><DD>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.<P><DD><DL><DT><B>Parameters:</B><DD><CODE>packetListener</CODE> - the packet listener to notify of sent packets.<DD><CODE>packetFilter</CODE> - the packet filter to use.</DL></DD></DL><HR><A NAME="removePacketWriterListener(org.jivesoftware.smack.PacketListener)"><!-- --></A><H3>removePacketWriterListener</H3><PRE>public void <B>removePacketWriterListener</B>(<A HREF="../../../org/jivesoftware/smack/PacketListener.html" title="interface in org.jivesoftware.smack">PacketListener</A>&nbsp;packetListener)</PRE><DL><DD>Removes a packet listener from this connection.<P><DD><DL><DT><B>Parameters:</B><DD><CODE>packetListener</CODE> - the packet listener to remove.</DL></DD></DL><HR>

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?