xmppconnection.html
来自「开源项目smack的API文件」· HTML 代码 · 共 1,263 行 · 第 1/5 页
HTML
1,263 行
<!-- ============ FIELD DETAIL =========== --><A NAME="field_detail"><!-- --></A><TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY=""><TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"><TH ALIGN="left" COLSPAN="1"><FONT SIZE="+2"><B>Field Detail</B></FONT></TH></TR></TABLE><A NAME="DEBUG_ENABLED"><!-- --></A><H3>DEBUG_ENABLED</H3><PRE>public static boolean <B>DEBUG_ENABLED</B></PRE><DL><DD>Value that indicates whether debugging is enabled. When enabled, a debug window will apear for each new connection that will contain the following information:<ul> <li> Client Traffic -- raw XML traffic generated by Smack and sent to the server. <li> Server Traffic -- raw XML traffic sent by the server to the client. <li> Interpreted Packets -- shows XML packets from the server as parsed by Smack. </ul> <p/> Debugging can be enabled by setting this field to true, or by setting the Java system property <tt>smack.debugEnabled</tt> to true. The system property can be set on the command line such as "java SomeApp -Dsmack.debugEnabled=true".<P><DL></DL></DL><!-- ========= CONSTRUCTOR DETAIL ======== --><A NAME="constructor_detail"><!-- --></A><TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY=""><TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"><TH ALIGN="left" COLSPAN="1"><FONT SIZE="+2"><B>Constructor Detail</B></FONT></TH></TR></TABLE><A NAME="XMPPConnection(java.lang.String)"><!-- --></A><H3>XMPPConnection</H3><PRE>public <B>XMPPConnection</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)</PRE><DL><DD>Creates a new connection to the specified XMPP server. A DNS SRV lookup will be performed to determine the IP address and port corresponding to the service name; if that lookup fails, it's assumed that server resides at <tt>serviceName</tt> with the default port of 5222. Encrypted connections (TLS) will be used if available, stream compression is disabled, and standard SASL mechanisms will be used for authentication.<p> <p/> This is the simplest constructor for connecting to an XMPP server. Alternatively, you can get fine-grained control over connection settings using the <A HREF="../../../org/jivesoftware/smack/XMPPConnection.html#XMPPConnection(org.jivesoftware.smack.ConnectionConfiguration)"><CODE>XMPPConnection(ConnectionConfiguration)</CODE></A> constructor.<p> <p/> Note that XMPPConnection constructors do not establish a connection to the server and you must call <A HREF="../../../org/jivesoftware/smack/XMPPConnection.html#connect()"><CODE>connect()</CODE></A>.<P><DL><DT><B>Parameters:</B><DD><CODE>serviceName</CODE> - the name of the XMPP server to connect to; e.g. <tt>example.com</tt>.</DL></DL><HR><A NAME="XMPPConnection(org.jivesoftware.smack.ConnectionConfiguration)"><!-- --></A><H3>XMPPConnection</H3><PRE>public <B>XMPPConnection</B>(<A HREF="../../../org/jivesoftware/smack/ConnectionConfiguration.html" title="class in org.jivesoftware.smack">ConnectionConfiguration</A> config)</PRE><DL><DD>Creates a new XMPP connection using the specified connection configuration.<p> <p/> Manually specifying connection configuration information is suitable for advanced users of the API. In many cases, using the <A HREF="../../../org/jivesoftware/smack/XMPPConnection.html#XMPPConnection(java.lang.String)"><CODE>XMPPConnection(String)</CODE></A> constructor is a better approach.<p> <p/> Note that XMPPConnection constructors do not establish a connection to the server and you must call <A HREF="../../../org/jivesoftware/smack/XMPPConnection.html#connect()"><CODE>connect()</CODE></A>.<P><DL><DT><B>Parameters:</B><DD><CODE>config</CODE> - the connection configuration.</DL></DL><!-- ============ METHOD DETAIL ========== --><A NAME="method_detail"><!-- --></A><TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY=""><TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"><TH ALIGN="left" COLSPAN="1"><FONT SIZE="+2"><B>Method Detail</B></FONT></TH></TR></TABLE><A NAME="getConnectionID()"><!-- --></A><H3>getConnectionID</H3><PRE>public <A HREF="http://java.sun.com/j2se/1.3/docs/api/java/lang/String.html" title="class or interface in java.lang">String</A> <B>getConnectionID</B>()</PRE><DL><DD>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.<P><DD><DL><DT><B>Returns:</B><DD>the ID of this connection returned from the XMPP server or <tt>null</tt> if not connected to the server.</DL></DD></DL><HR><A NAME="getServiceName()"><!-- --></A><H3>getServiceName</H3><PRE>public <A HREF="http://java.sun.com/j2se/1.3/docs/api/java/lang/String.html" title="class or interface in java.lang">String</A> <B>getServiceName</B>()</PRE><DL><DD>Returns the name of the service provided by the XMPP server for this connection. After authenticating with the server the returned value may be different.<P><DD><DL><DT><B>Returns:</B><DD>the name of the service provided by the XMPP server.</DL></DD></DL><HR><A NAME="getHost()"><!-- --></A><H3>getHost</H3><PRE>public <A HREF="http://java.sun.com/j2se/1.3/docs/api/java/lang/String.html" title="class or interface in java.lang">String</A> <B>getHost</B>()</PRE><DL><DD>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.<P><DD><DL><DT><B>Returns:</B><DD>the host name of the server where the XMPP server is running.</DL></DD></DL><HR><A NAME="getPort()"><!-- --></A><H3>getPort</H3><PRE>public int <B>getPort</B>()</PRE><DL><DD>Returns the port number of the XMPP server for this connection. The default port for normal connections is 5222. The default port for SSL connections is 5223.<P><DD><DL><DT><B>Returns:</B><DD>the port number of the XMPP server.</DL></DD></DL><HR><A NAME="getUser()"><!-- --></A><H3>getUser</H3><PRE>public <A HREF="http://java.sun.com/j2se/1.3/docs/api/java/lang/String.html" title="class or interface in java.lang">String</A> <B>getUser</B>()</PRE><DL><DD>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.<P><DD><DL><DT><B>Returns:</B><DD>the full XMPP address of the user logged in.</DL></DD></DL><HR><A NAME="login(java.lang.String, java.lang.String)"><!-- --></A><H3>login</H3><PRE>public void <B>login</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> username, <A HREF="http://java.sun.com/j2se/1.3/docs/api/java/lang/String.html" title="class or interface in java.lang">String</A> password) throws <A HREF="../../../org/jivesoftware/smack/XMPPException.html" title="class in org.jivesoftware.smack">XMPPException</A></PRE><DL><DD>Logs in to the server using the strongest authentication mode supported by the server, then sets presence to available. 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.<P><DD><DL><DT><B>Parameters:</B><DD><CODE>username</CODE> - the username.<DD><CODE>password</CODE> - the password.<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.</DL></DD></DL><HR><A NAME="login(java.lang.String, java.lang.String, java.lang.String)"><!-- --></A><H3>login</H3><PRE>public void <B>login</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> username, <A HREF="http://java.sun.com/j2se/1.3/docs/api/java/lang/String.html" title="class or interface in java.lang">String</A> password, <A HREF="http://java.sun.com/j2se/1.3/docs/api/java/lang/String.html" title="class or interface in java.lang">String</A> resource) throws <A HREF="../../../org/jivesoftware/smack/XMPPException.html" title="class in org.jivesoftware.smack">XMPPException</A></PRE><DL><DD>Logs in to the server using the strongest authentication mode supported by the server, then sets presence to available. 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.<P><DD><DL><DT><B>Parameters:</B><DD><CODE>username</CODE> - the username.<DD><CODE>password</CODE> - the password.<DD><CODE>resource</CODE> - the resource.<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.<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="login(java.lang.String, java.lang.String, java.lang.String, boolean)"><!-- --></A><H3>login</H3><PRE>public void <B>login</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> username, <A HREF="http://java.sun.com/j2se/1.3/docs/api/java/lang/String.html" title="class or interface in java.lang">String</A> password, <A HREF="http://java.sun.com/j2se/1.3/docs/api/java/lang/String.html" title="class or interface in java.lang">String</A> resource, boolean sendPresence) throws <A HREF="../../../org/jivesoftware/smack/XMPPException.html" title="class in org.jivesoftware.smack">XMPPException</A></PRE><DL><DD>Logs in to the server using the strongest authentication mode supported by the server. If the server supports SASL authentication then the user will be authenticated using SASL if not Non-SASL authentication will be tried. An available presence may optionally be sent. 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.<p> <p/> Before logging in (i.e. authenticate) to the server the connection must be connected. For compatibility and easiness of use the connection will automatically connect to the server if not already connected.<P><DD><DL><DT><B>Parameters:</B><DD><CODE>username</CODE> - the username.<DD><CODE>password</CODE> - the password.<DD><CODE>resource</CODE> - the resource.<DD><CODE>sendPresence</CODE> - if <tt>true</tt> an available presence will be sent automatically after login is completed.<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.<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="loginAnonymously()"><!-- --></A><H3>loginAnonymously</H3><PRE>public void <B>loginAnonymously</B>() throws <A HREF="../../../org/jivesoftware/smack/XMPPException.html" title="class in org.jivesoftware.smack">XMPPException</A></PRE><DL>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?