xmppconnection.html
来自「开源项目smack的API文件」· HTML 代码 · 共 1,263 行 · 第 1/5 页
HTML
1,263 行
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><!--NewPage--><HTML><HEAD><!-- Generated by javadoc (build 1.5.0_07) on Thu Jun 21 14:48:18 PDT 2007 --><TITLE>XMPPConnection (Smack 3.0.4 Documentation)</TITLE><META NAME="keywords" CONTENT="org.jivesoftware.smack.XMPPConnection class"><LINK REL ="stylesheet" TYPE="text/css" HREF="../../../stylesheet.css" TITLE="Style"><SCRIPT type="text/javascript">function windowTitle(){ parent.document.title="XMPPConnection (Smack 3.0.4 Documentation)";}</SCRIPT><NOSCRIPT></NOSCRIPT></HEAD><BODY BGCOLOR="white" onload="windowTitle();"><!-- ========= START OF TOP NAVBAR ======= --><A NAME="navbar_top"><!-- --></A><A HREF="#skip-navbar_top" title="Skip navigation links"></A><TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0" SUMMARY=""><TR><TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1"><A NAME="navbar_top_firstrow"><!-- --></A><TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3" SUMMARY=""> <TR ALIGN="center" VALIGN="top"> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../overview-summary.html"><FONT CLASS="NavBarFont1"><B>Overview</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A> </TD> <TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> <FONT CLASS="NavBarFont1Rev"><B>Class</B></FONT> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../index-all.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A> </TD> </TR></TABLE></TD><TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM><b>Smack</b></EM></TD></TR><TR><TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2"> <A HREF="../../../org/jivesoftware/smack/SmackConfiguration.html" title="class in org.jivesoftware.smack"><B>PREV CLASS</B></A> <A HREF="../../../org/jivesoftware/smack/XMPPException.html" title="class in org.jivesoftware.smack"><B>NEXT CLASS</B></A></FONT></TD><TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2"> <A HREF="../../../index.html?org/jivesoftware/smack/XMPPConnection.html" target="_top"><B>FRAMES</B></A> <A HREF="XMPPConnection.html" target="_top"><B>NO FRAMES</B></A> <SCRIPT type="text/javascript"> <!-- if(window==top) { document.writeln('<A HREF="../../../allclasses-noframe.html"><B>All Classes</B></A>'); } //--></SCRIPT><NOSCRIPT> <A HREF="../../../allclasses-noframe.html"><B>All Classes</B></A></NOSCRIPT></FONT></TD></TR><TR><TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2"> SUMMARY: NESTED | <A HREF="#field_summary">FIELD</A> | <A HREF="#constructor_summary">CONSTR</A> | <A HREF="#method_summary">METHOD</A></FONT></TD><TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">DETAIL: <A HREF="#field_detail">FIELD</A> | <A HREF="#constructor_detail">CONSTR</A> | <A HREF="#method_detail">METHOD</A></FONT></TD></TR></TABLE><A NAME="skip-navbar_top"></A><!-- ========= END OF TOP NAVBAR ========= --><HR><!-- ======== START OF CLASS DATA ======== --><H2><FONT SIZE="-1">org.jivesoftware.smack</FONT><BR>Class XMPPConnection</H2><PRE><A HREF="http://java.sun.com/j2se/1.3/docs/api/java/lang/Object.html" title="class or interface in java.lang">java.lang.Object</A> <IMG SRC="../../../resources/inherit.gif" ALT="extended by "><B>org.jivesoftware.smack.XMPPConnection</B></PRE><HR><DL><DT><PRE>public class <B>XMPPConnection</B><DT>extends <A HREF="http://java.sun.com/j2se/1.3/docs/api/java/lang/Object.html" title="class or interface in java.lang">Object</A></DL></PRE><P>Creates a connection to a XMPP server. A simple use of this API might look like the following: <pre> // Create a connection to the igniterealtime.org XMPP server. XMPPConnection con = new XMPPConnection("igniterealtime.org"); // 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. Chat chat = connection.getChatManager().createChat("jdoe@igniterealtime.org"</font>, new MessageListener() { <p/> 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> <p/> XMPPConnections can be reused between connections. This means that an XMPPConnection may be connected, disconnected and then connected again. Listeners of the XMPPConnection will be retained accross connections.<p> <p/> If a connected XMPPConnection gets disconnected abruptly then it will try to reconnect again. To stop the reconnection process, use <A HREF="../../../org/jivesoftware/smack/XMPPConnection.html#disconnect()"><CODE>disconnect()</CODE></A>. Once stopped you can use <A HREF="../../../org/jivesoftware/smack/XMPPConnection.html#connect()"><CODE>connect()</CODE></A> to manually connect to the server.<P><P><DL><DT><B>Author:</B></DT> <DD>Matt Tucker</DD></DL><HR><P><!-- =========== FIELD SUMMARY =========== --><A NAME="field_summary"><!-- --></A><TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY=""><TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"><TH ALIGN="left" COLSPAN="2"><FONT SIZE="+2"><B>Field Summary</B></FONT></TH></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>static boolean</CODE></FONT></TD><TD><CODE><B><A HREF="../../../org/jivesoftware/smack/XMPPConnection.html#DEBUG_ENABLED">DEBUG_ENABLED</A></B></CODE><BR> Value that indicates whether debugging is enabled.</TD></TR></TABLE> <!-- ======== CONSTRUCTOR SUMMARY ======== --><A NAME="constructor_summary"><!-- --></A><TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY=""><TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"><TH ALIGN="left" COLSPAN="2"><FONT SIZE="+2"><B>Constructor Summary</B></FONT></TH></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD><CODE><B><A HREF="../../../org/jivesoftware/smack/XMPPConnection.html#XMPPConnection(org.jivesoftware.smack.ConnectionConfiguration)">XMPPConnection</A></B>(<A HREF="../../../org/jivesoftware/smack/ConnectionConfiguration.html" title="class in org.jivesoftware.smack">ConnectionConfiguration</A> config)</CODE><BR> Creates a new XMPP connection using the specified connection configuration.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD><CODE><B><A HREF="../../../org/jivesoftware/smack/XMPPConnection.html#XMPPConnection(java.lang.String)">XMPPConnection</A></B>(<A HREF="http://java.sun.com/j2se/1.3/docs/api/java/lang/String.html" title="class or interface in java.lang">String</A> serviceName)</CODE><BR> Creates a new connection to the specified XMPP server.</TD></TR></TABLE> <!-- ========== METHOD SUMMARY =========== --><A NAME="method_summary"><!-- --></A><TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY=""><TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"><TH ALIGN="left" COLSPAN="2"><FONT SIZE="+2"><B>Method Summary</B></FONT></TH></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>static void</CODE></FONT></TD><TD><CODE><B><A HREF="../../../org/jivesoftware/smack/XMPPConnection.html#addConnectionCreationListener(org.jivesoftware.smack.ConnectionCreationListener)">addConnectionCreationListener</A></B>(<A HREF="../../../org/jivesoftware/smack/ConnectionCreationListener.html" title="interface in org.jivesoftware.smack">ConnectionCreationListener</A> connectionCreationListener)</CODE><BR> Adds a new listener that will be notified when new XMPPConnections are created.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE> void</CODE></FONT></TD><TD><CODE><B><A HREF="../../../org/jivesoftware/smack/XMPPConnection.html#addConnectionListener(org.jivesoftware.smack.ConnectionListener)">addConnectionListener</A></B>(<A HREF="../../../org/jivesoftware/smack/ConnectionListener.html" title="interface in org.jivesoftware.smack">ConnectionListener</A> connectionListener)</CODE><BR> Adds a connection listener to this connection that will be notified when the connection closes or fails.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE> void</CODE></FONT></TD><TD><CODE><B><A HREF="../../../org/jivesoftware/smack/XMPPConnection.html#addPacketListener(org.jivesoftware.smack.PacketListener, org.jivesoftware.smack.filter.PacketFilter)">addPacketListener</A></B>(<A HREF="../../../org/jivesoftware/smack/PacketListener.html" title="interface in org.jivesoftware.smack">PacketListener</A> packetListener, <A HREF="../../../org/jivesoftware/smack/filter/PacketFilter.html" title="interface in org.jivesoftware.smack.filter">PacketFilter</A> packetFilter)</CODE><BR> Registers a packet listener with this connection.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE> void</CODE></FONT></TD><TD><CODE><B><A HREF="../../../org/jivesoftware/smack/XMPPConnection.html#addPacketWriterInterceptor(org.jivesoftware.smack.PacketInterceptor, org.jivesoftware.smack.filter.PacketFilter)">addPacketWriterInterceptor</A></B>(<A HREF="../../../org/jivesoftware/smack/PacketInterceptor.html" title="interface in org.jivesoftware.smack">PacketInterceptor</A> packetInterceptor, <A HREF="../../../org/jivesoftware/smack/filter/PacketFilter.html" title="interface in org.jivesoftware.smack.filter">PacketFilter</A> packetFilter)</CODE><BR> Registers a packet interceptor with this connection.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE> void</CODE></FONT></TD><TD><CODE><B><A HREF="../../../org/jivesoftware/smack/XMPPConnection.html#addPacketWriterListener(org.jivesoftware.smack.PacketListener, org.jivesoftware.smack.filter.PacketFilter)">addPacketWriterListener</A></B>(<A HREF="../../../org/jivesoftware/smack/PacketListener.html" title="interface in org.jivesoftware.smack">PacketListener</A> packetListener, <A HREF="../../../org/jivesoftware/smack/filter/PacketFilter.html" title="interface in org.jivesoftware.smack.filter">PacketFilter</A> packetFilter)</CODE><BR> Registers a packet listener with this connection.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE> void</CODE></FONT></TD><TD><CODE><B><A HREF="../../../org/jivesoftware/smack/XMPPConnection.html#connect()">connect</A></B>()</CODE><BR> Establishes a connection to the XMPP server and performs an automatic login only if the previous connection state was logged (authenticated).</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE> <A HREF="../../../org/jivesoftware/smack/PacketCollector.html" title="class in org.jivesoftware.smack">PacketCollector</A></CODE></FONT></TD><TD><CODE><B><A HREF="../../../org/jivesoftware/smack/XMPPConnection.html#createPacketCollector(org.jivesoftware.smack.filter.PacketFilter)">createPacketCollector</A></B>(<A HREF="../../../org/jivesoftware/smack/filter/PacketFilter.html" title="interface in org.jivesoftware.smack.filter">PacketFilter</A> packetFilter)</CODE><BR> Creates a new packet collector for this connection.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE> void</CODE></FONT></TD><TD><CODE><B><A HREF="../../../org/jivesoftware/smack/XMPPConnection.html#disconnect()">disconnect</A></B>()</CODE><BR>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?