com.google.code.yanf4j.core
Interface Session

All Known Subinterfaces:
NioSession
All Known Implementing Classes:
AbstractNioSession, AbstractSession, MemcachedTCPSession, NioTCPSession

public interface Session

Abstract connection

Author:
dennis

Nested Class Summary
static class Session.SessionStatus
           
 
Method Summary
 void clearAttributes()
          Clear attributes
 void close()
          Close session
 void flush()
          Flush the write queue,this method may be no effect if OP_WRITE is running.
 java.lang.Object getAttribute(java.lang.String key)
          Return attribute associated with key
 CodecFactory.Decoder getDecoder()
          Return current decoder
 CodecFactory.Encoder getEncoder()
          Return current encoder
 Handler getHandler()
           
 long getLastOperationTimeStamp()
          Return last operation timestamp,operation include read,write,idle
 java.net.InetAddress getLocalAddress()
           
 java.nio.ByteOrder getReadBufferByteOrder()
          Return the session read buffer's byte order,big end or little end.
 java.net.InetSocketAddress getRemoteSocketAddress()
          Return the remote end's InetSocketAddress
 long getScheduleWritenBytes()
          Return the bytes in write queue,there bytes is in memory.Use this method to controll writing speed.
 long getSessionIdleTimeout()
           
 long getSessionTimeout()
           
 boolean isClosed()
          Check if session is closed
 boolean isExpired()
          Return true if session is expired,session is expired beacause you set the sessionTimeout,if since session's last operation form now is over this vlaue,isExpired return true,and Handler.onExpired() will be invoked.
 boolean isHandleReadWriteConcurrently()
          Return true if allow handling read and write concurrently,default is true.
 boolean isIdle()
          Check if session is idle
 boolean isLoopbackConnection()
          return true if it is a loopback connection
 boolean isUseBlockingRead()
          Return true if using blocking read
 boolean isUseBlockingWrite()
          Return true if using blocking write
 void removeAttribute(java.lang.String key)
          Remove attribute
 void setAttribute(java.lang.String key, java.lang.Object value)
          Set a attribute attched with this session
 java.lang.Object setAttributeIfAbsent(java.lang.String key, java.lang.Object value)
           
 void setDecoder(CodecFactory.Decoder decoder)
           
 void setEncoder(CodecFactory.Encoder encoder)
          Set encoder
 void setHandleReadWriteConcurrently(boolean handleReadWriteConcurrently)
           
 void setReadBufferByteOrder(java.nio.ByteOrder readBufferByteOrder)
           
 void setSessionIdleTimeout(long sessionIdleTimeout)
           
 void setSessionTimeout(long sessionTimeout)
           
 void setUseBlockingRead(boolean useBlockingRead)
           
 void setUseBlockingWrite(boolean useBlockingWrite)
          Set if using blocking write
 void start()
          Start session
 void write(java.lang.Object packet)
          Write a message,if you don't care when the message is written
 

Method Detail

start

void start()
Start session


write

void write(java.lang.Object packet)
Write a message,if you don't care when the message is written

Parameters:
packet -

isClosed

boolean isClosed()
Check if session is closed

Returns:

close

void close()
Close session


getRemoteSocketAddress

java.net.InetSocketAddress getRemoteSocketAddress()
Return the remote end's InetSocketAddress

Returns:

getLocalAddress

java.net.InetAddress getLocalAddress()

isUseBlockingWrite

boolean isUseBlockingWrite()
Return true if using blocking write

Returns:

setUseBlockingWrite

void setUseBlockingWrite(boolean useBlockingWrite)
Set if using blocking write

Parameters:
useBlockingWrite -

isUseBlockingRead

boolean isUseBlockingRead()
Return true if using blocking read

Returns:

setUseBlockingRead

void setUseBlockingRead(boolean useBlockingRead)

flush

void flush()
Flush the write queue,this method may be no effect if OP_WRITE is running.


isExpired

boolean isExpired()
Return true if session is expired,session is expired beacause you set the sessionTimeout,if since session's last operation form now is over this vlaue,isExpired return true,and Handler.onExpired() will be invoked.

Returns:

isIdle

boolean isIdle()
Check if session is idle

Returns:

getEncoder

CodecFactory.Encoder getEncoder()
Return current encoder

Returns:

setEncoder

void setEncoder(CodecFactory.Encoder encoder)
Set encoder

Parameters:
encoder -

getDecoder

CodecFactory.Decoder getDecoder()
Return current decoder

Returns:

setDecoder

void setDecoder(CodecFactory.Decoder decoder)

isHandleReadWriteConcurrently

boolean isHandleReadWriteConcurrently()
Return true if allow handling read and write concurrently,default is true.

Returns:

setHandleReadWriteConcurrently

void setHandleReadWriteConcurrently(boolean handleReadWriteConcurrently)

getReadBufferByteOrder

java.nio.ByteOrder getReadBufferByteOrder()
Return the session read buffer's byte order,big end or little end.

Returns:

setReadBufferByteOrder

void setReadBufferByteOrder(java.nio.ByteOrder readBufferByteOrder)

setAttribute

void setAttribute(java.lang.String key,
                  java.lang.Object value)
Set a attribute attched with this session

Parameters:
key -
value -

removeAttribute

void removeAttribute(java.lang.String key)
Remove attribute

Parameters:
key -

getAttribute

java.lang.Object getAttribute(java.lang.String key)
Return attribute associated with key

Parameters:
key -
Returns:

clearAttributes

void clearAttributes()
Clear attributes


getScheduleWritenBytes

long getScheduleWritenBytes()
Return the bytes in write queue,there bytes is in memory.Use this method to controll writing speed.

Returns:

getLastOperationTimeStamp

long getLastOperationTimeStamp()
Return last operation timestamp,operation include read,write,idle

Returns:

isLoopbackConnection

boolean isLoopbackConnection()
return true if it is a loopback connection

Returns:

getSessionIdleTimeout

long getSessionIdleTimeout()

setSessionIdleTimeout

void setSessionIdleTimeout(long sessionIdleTimeout)

getSessionTimeout

long getSessionTimeout()

setSessionTimeout

void setSessionTimeout(long sessionTimeout)

setAttributeIfAbsent

java.lang.Object setAttributeIfAbsent(java.lang.String key,
                                      java.lang.Object value)

getHandler

Handler getHandler()


Copyright © 2011. All Rights Reserved.