⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 iosession.html

📁 MINA+API 关于MINA的API
💻 HTML
📖 第 1 页 / 共 5 页
字号:
<A NAME="getConfig()"><!-- --></A><H3>getConfig</H3><PRE><A HREF="../../../../org/apache/mina/common/IoSessionConfig.html" title="interface in org.apache.mina.common">IoSessionConfig</A> <B>getConfig</B>()</PRE><DL><DD>Returns the configuration of this session.<P><DD><DL></DL></DD></DL><HR><A NAME="getFilterChain()"><!-- --></A><H3>getFilterChain</H3><PRE><A HREF="../../../../org/apache/mina/common/IoFilterChain.html" title="interface in org.apache.mina.common">IoFilterChain</A> <B>getFilterChain</B>()</PRE><DL><DD>Returns the filter chain that only affects this session.<P><DD><DL></DL></DD></DL><HR><A NAME="getTransportMetadata()"><!-- --></A><H3>getTransportMetadata</H3><PRE><A HREF="../../../../org/apache/mina/common/TransportMetadata.html" title="interface in org.apache.mina.common">TransportMetadata</A> <B>getTransportMetadata</B>()</PRE><DL><DD>Returns the <A HREF="../../../../org/apache/mina/common/TransportMetadata.html" title="interface in org.apache.mina.common"><CODE>TransportMetadata</CODE></A> that this session runs on.<P><DD><DL></DL></DD></DL><HR><A NAME="read()"><!-- --></A><H3>read</H3><PRE><A HREF="../../../../org/apache/mina/common/ReadFuture.html" title="interface in org.apache.mina.common">ReadFuture</A> <B>read</B>()</PRE><DL><DD>Returns a <A HREF="../../../../org/apache/mina/common/ReadFuture.html" title="interface in org.apache.mina.common"><CODE>ReadFuture</CODE></A> which is notified when a new message is received, the connection is closed or an exception is caught.  This operation is especially useful when you implement a client application. However, please note that this operation is disabled by default and throw <A HREF="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/IllegalStateException.html?is-external=true" title="class or interface in java.lang"><CODE>IllegalStateException</CODE></A> because all received events must be queued somewhere to support this operation, possibly leading to memory leak.  This means you have to keep calling <A HREF="../../../../org/apache/mina/common/IoSession.html#read()"><CODE>read()</CODE></A> once you enabled this operation.  To enable this operation, please call <A HREF="../../../../org/apache/mina/common/IoSessionConfig.html#setUseReadOperation(boolean)"><CODE>IoSessionConfig.setUseReadOperation(boolean)</CODE></A> with <tt>true</tt>.<P><DD><DL><DT><B>Throws:</B><DD><CODE><A HREF="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/IllegalStateException.html?is-external=true" title="class or interface in java.lang">IllegalStateException</A></CODE> - if <A HREF="../../../../org/apache/mina/common/IoSessionConfig.html#setUseReadOperation(boolean)"><CODE>useReadOperation</CODE></A> option has not been enabled.</DL></DD></DL><HR><A NAME="write(java.lang.Object)"><!-- --></A><H3>write</H3><PRE><A HREF="../../../../org/apache/mina/common/WriteFuture.html" title="interface in org.apache.mina.common">WriteFuture</A> <B>write</B>(<A HREF="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Object.html?is-external=true" title="class or interface in java.lang">Object</A>&nbsp;message)</PRE><DL><DD>Writes the specified <code>message</code> to remote peer.  This operation is asynchronous; <A HREF="../../../../org/apache/mina/common/IoHandler.html#messageSent(org.apache.mina.common.IoSession, java.lang.Object)"><CODE>IoHandler.messageSent(IoSession,Object)</CODE></A> will be invoked when the message is actually sent to remote peer. You can also wait for the returned <A HREF="../../../../org/apache/mina/common/WriteFuture.html" title="interface in org.apache.mina.common"><CODE>WriteFuture</CODE></A> if you want to wait for the message actually written.<P><DD><DL></DL></DD></DL><HR><A NAME="write(java.lang.Object, java.net.SocketAddress)"><!-- --></A><H3>write</H3><PRE><A HREF="../../../../org/apache/mina/common/WriteFuture.html" title="interface in org.apache.mina.common">WriteFuture</A> <B>write</B>(<A HREF="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Object.html?is-external=true" title="class or interface in java.lang">Object</A>&nbsp;message,                  <A HREF="http://java.sun.com/j2se/1.5.0/docs/api/java/net/SocketAddress.html?is-external=true" title="class or interface in java.net">SocketAddress</A>&nbsp;destination)</PRE><DL><DD>(Optional) Writes the specified <tt>message</tt> to the specified <tt>destination</tt>. This operation is asynchronous; <A HREF="../../../../org/apache/mina/common/IoHandler.html#messageSent(org.apache.mina.common.IoSession, java.lang.Object)"><CODE>IoHandler.messageSent(IoSession, Object)</CODE></A> will be invoked when the message is actually sent to remote peer. You can also wait for the returned <A HREF="../../../../org/apache/mina/common/WriteFuture.html" title="interface in org.apache.mina.common"><CODE>WriteFuture</CODE></A> if you want to wait for the message actually written. <p> When you implement a client that receives a broadcast message from a server such as DHCP server, the client might need to send a response message for the broadcast message the server sent.  Because the remote address of the session is not the address of the server in case of broadcasting, there should be a way to specify the destination when you write the response message. This interface provides <A HREF="../../../../org/apache/mina/common/IoSession.html#write(java.lang.Object, java.net.SocketAddress)"><CODE>write(Object, SocketAddress)</CODE></A> method so you can specify the destination.<P><DD><DL><DT><B>Parameters:</B><DD><CODE>destination</CODE> - <tt>null</tt> if you want the message sent to the                    default remote address<DT><B>Throws:</B><DD><CODE><A HREF="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/UnsupportedOperationException.html?is-external=true" title="class or interface in java.lang">UnsupportedOperationException</A></CODE> - if this operation is not supported</DL></DD></DL><HR><A NAME="close()"><!-- --></A><H3>close</H3><PRE><A HREF="../../../../org/apache/mina/common/CloseFuture.html" title="interface in org.apache.mina.common">CloseFuture</A> <B>close</B>()</PRE><DL><DD>Closes this session immediately.  This operation is asynchronous. Wait for the returned <A HREF="../../../../org/apache/mina/common/CloseFuture.html" title="interface in org.apache.mina.common"><CODE>CloseFuture</CODE></A> if you want to wait for the session actually closed.<P><DD><DL></DL></DD></DL><HR><A NAME="closeOnFlush()"><!-- --></A><H3>closeOnFlush</H3><PRE><A HREF="../../../../org/apache/mina/common/CloseFuture.html" title="interface in org.apache.mina.common">CloseFuture</A> <B>closeOnFlush</B>()</PRE><DL><DD>Closes this session after all queued write requests are flushed. This operation is asynchronous.  Wait for the returned <A HREF="../../../../org/apache/mina/common/CloseFuture.html" title="interface in org.apache.mina.common"><CODE>CloseFuture</CODE></A> if you want to wait for the session actually closed.<P><DD><DL></DL></DD></DL><HR><A NAME="close(boolean)"><!-- --></A><H3>close</H3><PRE><A HREF="../../../../org/apache/mina/common/CloseFuture.html" title="interface in org.apache.mina.common">CloseFuture</A> <B>close</B>(boolean&nbsp;immediately)</PRE><DL><DD>Closes this session immediately or after all queued write requests are flushed.  This operation is asynchronous.  Wait for the returned <A HREF="../../../../org/apache/mina/common/CloseFuture.html" title="interface in org.apache.mina.common"><CODE>CloseFuture</CODE></A> if you want to wait for the session actually closed.<P><DD><DL><DT><B>Parameters:</B><DD><CODE>immediately</CODE> - <code>true</code> to close this session immediately                    (i.e. <A HREF="../../../../org/apache/mina/common/IoSession.html#close()"><CODE>close()</CODE></A>).                    <code>false</code> to close this session after all queued                    write requests are flushed (i.e. <A HREF="../../../../org/apache/mina/common/IoSession.html#closeOnFlush()"><CODE>closeOnFlush()</CODE></A>).</DL></DD></DL><HR><A NAME="getAttachment()"><!-- --></A><H3>getAttachment</H3><PRE><FONT SIZE="-1"><A HREF="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Deprecated.html?is-external=true" title="class or interface in java.lang">@Deprecated</A></FONT><A HREF="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Object.html?is-external=true" title="class or interface in java.lang">Object</A> <B>getAttachment</B>()</PRE><DL><DD><B>Deprecated.</B>&nbsp;<I>Use <A HREF="../../../../org/apache/mina/common/IoSession.html#getAttribute(java.lang.Object)"><CODE>getAttribute(Object)</CODE></A> instead.</I><P><DD>Returns an attachment of this session. This method is identical with <tt>getAttribute( "" )</tt>.<P><DD><DL></DL></DD></DL><HR><A NAME="setAttachment(java.lang.Object)"><!-- --></A><H3>setAttachment</H3><PRE><FONT SIZE="-1"><A HREF="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Deprecated.html?is-external=true" title="class or interface in java.lang">@Deprecated</A></FONT><A HREF="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Object.html?is-external=true" title="class or interface in java.lang">Object</A> <B>setAttachment</B>(<A HREF="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Object.html?is-external=true" title="class or interface in java.lang">Object</A>&nbsp;attachment)</PRE><DL><DD><B>Deprecated.</B>&nbsp;<I>Use <A HREF="../../../../org/apache/mina/common/IoSession.html#setAttribute(java.lang.Object, java.lang.Object)"><CODE>setAttribute(Object, Object)</CODE></A> instead.</I><P><DD>Sets an attachment of this session. This method is identical with <tt>setAttribute( "", attachment )</tt>.<P><DD><DL><DT><B>Returns:</B><DD>Old attachment.  <tt>null</tt> if it is new.</DL></DD></DL><HR><A NAME="getAttribute(java.lang.Object)"><!-- --></A><H3>getAttribute</H3><PRE><A HREF="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Object.html?is-external=true" title="class or interface in java.lang">Object</A> <B>getAttribute</B>(<A HREF="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Object.html?is-external=true" title="class or interface in java.lang">Object</A>&nbsp;key)</PRE><DL><DD>Returns the value of the user-defined attribute of this session.<P><DD><DL><DT><B>Parameters:</B><DD><CODE>key</CODE> - the key of the attribute<DT><B>Returns:</B><DD><tt>null</tt> if there is no attribute with the specified key</DL></DD></DL><HR><A NAME="getAttribute(java.lang.Object, java.lang.Object)"><!-- --></A><H3>getAttribute</H3><PRE><A HREF="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Object.html?is-external=true" title="class or interface in java.lang">Object</A> <B>getAttribute</B>(<A HREF="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Object.html?is-external=true" title="class or interface in java.lang">Object</A>&nbsp;key,                    <A HREF="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Object.html?is-external=true" title="class or interface in java.lang">Object</A>&nbsp;defaultValue)</PRE><DL><DD>Returns the value of user defined attribute associated with the specified key.  If there's no such attribute, the specified default value is associated with the specified key, and the default value is returned.  This method is same with the following code except that the operation is performed atomically. <pre> if (containsAttribute(key)) {     return getAttribute(key); } else {     setAttribute(key, defaultValue);     return defaultValue; } </pre><P><DD><DL></DL></DD></DL><HR><A NAME="setAttribute(java.lang.Object, java.lang.Object)"><!-- --></A><H3>setAttribute</H3><PRE><A HREF="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Object.html?is-external=true" title="class or interface in java.lang">Object</A> <B>setAttribute</B>(<A HREF="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Object.html?is-external=true" title="class or interface in java.lang">Object</A>&nbsp;key,                    <A HREF="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Object.html?is-external=true" title="class or interface in java.lang">Object</A>&nbsp;value)</PRE><DL><DD>Sets a user-defined attribute.

⌨️ 快捷键说明

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