Package com.google.code.yanf4j.nio.impl
Class AbstractNioSession
- java.lang.Object
-
- com.google.code.yanf4j.core.impl.AbstractSession
-
- com.google.code.yanf4j.nio.impl.AbstractNioSession
-
- All Implemented Interfaces:
Session,NioSession
- Direct Known Subclasses:
NioTCPSession
public abstract class AbstractNioSession extends AbstractSession implements NioSession
Abstract nio session
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface com.google.code.yanf4j.core.Session
Session.SessionStatus
-
-
Field Summary
Fields Modifier and Type Field Description protected java.nio.channels.SelectableChannelselectableChannelprotected SelectorManagerselectorManager-
Fields inherited from class com.google.code.yanf4j.core.impl.AbstractSession
attributes, closed, currentMessage, decoder, dispatchMessageDispatcher, encoder, handler, handleReadWriteConcurrently, lastOperationTimeStamp, log, loopback, readBuffer, scheduleWritenBytes, sessionIdleTimeout, sessionTimeout, statistics, useBlockingRead, useBlockingWrite, writeLock, writeQueue
-
-
Constructor Summary
Constructors Constructor Description AbstractNioSession(NioSessionConfig sessionConfig)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description java.nio.channels.SelectableChannelchannel()return the channel for this connectionprotected voidcloseChannel()protected longdoRealWrite(java.nio.channels.SelectableChannel channel, IoBuffer buffer)voidenableRead(java.nio.channels.Selector selector)Enable read eventvoidenableWrite(java.nio.channels.Selector selector)Enable write eventvoidflush()Flush the write queue,this method may be no effect if OP_WRITE is running.protected voidflush0()java.net.InetAddressgetLocalAddress()private voidinterestRead(java.nio.channels.SelectionKey key)private voidinterestWrite(java.nio.channels.SelectionKey key)voidonEvent(EventType event, java.nio.channels.Selector selector)�ɷ�IO�¼�protected voidonRead(java.nio.channels.SelectionKey key)protected voidonWrite(java.nio.channels.SelectionKey key)protected abstract voidreadFromBuffer()protected voidregisterSession()protected booleanschduleWriteMessage(WriteMessage writeMessage)protected voidstart0()protected voidunregisterChannel()protected voidunregisterSession()voidwriteFromUserCode(WriteMessage message)protected abstract java.lang.ObjectwriteToChannel(WriteMessage msg)-
Methods inherited from class com.google.code.yanf4j.core.impl.AbstractSession
clearAttributes, clearWriteQueue, close, decode, dispatchReceivedMessage, getAttribute, getDecoder, getDispatchMessageDispatcher, getEncoder, getHandler, getLastOperationTimeStamp, getReadBuffer, getReadBufferByteOrder, getScheduleWritenBytes, getSessionIdleTimeout, getSessionTimeout, getStatistics, getWriteLock, getWriteQueue, isClosed, isExpired, isHandleReadWriteConcurrently, isIdle, isLoopbackConnection, isUseBlockingRead, isUseBlockingWrite, onClosed, onConnected, onCreated, onException, onExpired, onIdle, onStarted, preprocessWriteMessage, removeAttribute, setAttribute, setAttributeIfAbsent, setClosed, setDecoder, setEncoder, setHandleReadWriteConcurrently, setReadBuffer, setReadBufferByteOrder, setSessionIdleTimeout, setSessionTimeout, setUseBlockingRead, setUseBlockingWrite, start, transferFrom, transferTo, updateTimeStamp, wrapMessage, write
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.google.code.yanf4j.core.Session
clearAttributes, close, getAttribute, getDecoder, getEncoder, getHandler, getLastOperationTimeStamp, getReadBufferByteOrder, getRemoteSocketAddress, getScheduleWritenBytes, getSessionIdleTimeout, getSessionTimeout, isClosed, isExpired, isHandleReadWriteConcurrently, isIdle, isLoopbackConnection, isUseBlockingRead, isUseBlockingWrite, removeAttribute, setAttribute, setAttributeIfAbsent, setDecoder, setEncoder, setHandleReadWriteConcurrently, setReadBufferByteOrder, setSessionIdleTimeout, setSessionTimeout, setUseBlockingRead, setUseBlockingWrite, start, write
-
-
-
-
Field Detail
-
selectorManager
protected SelectorManager selectorManager
-
selectableChannel
protected java.nio.channels.SelectableChannel selectableChannel
-
-
Constructor Detail
-
AbstractNioSession
public AbstractNioSession(NioSessionConfig sessionConfig)
-
-
Method Detail
-
channel
public java.nio.channels.SelectableChannel channel()
Description copied from interface:NioSessionreturn the channel for this connection- Specified by:
channelin interfaceNioSession- Returns:
-
enableRead
public final void enableRead(java.nio.channels.Selector selector)
Description copied from interface:NioSessionEnable read event- Specified by:
enableReadin interfaceNioSession
-
interestRead
private void interestRead(java.nio.channels.SelectionKey key)
-
start0
protected void start0()
- Specified by:
start0in classAbstractSession
-
getLocalAddress
public java.net.InetAddress getLocalAddress()
- Specified by:
getLocalAddressin interfaceSession
-
writeToChannel
protected abstract java.lang.Object writeToChannel(WriteMessage msg) throws java.nio.channels.ClosedChannelException, java.io.IOException
- Throws:
java.nio.channels.ClosedChannelExceptionjava.io.IOException
-
onWrite
protected void onWrite(java.nio.channels.SelectionKey key)
-
enableWrite
public final void enableWrite(java.nio.channels.Selector selector)
Description copied from interface:NioSessionEnable write event- Specified by:
enableWritein interfaceNioSession
-
interestWrite
private void interestWrite(java.nio.channels.SelectionKey key)
-
onRead
protected void onRead(java.nio.channels.SelectionKey key)
-
readFromBuffer
protected abstract void readFromBuffer()
-
closeChannel
protected void closeChannel() throws java.io.IOException- Specified by:
closeChannelin classAbstractSession- Throws:
java.io.IOException
-
unregisterChannel
protected final void unregisterChannel() throws java.io.IOException- Throws:
java.io.IOException
-
registerSession
protected final void registerSession()
-
unregisterSession
protected void unregisterSession()
-
writeFromUserCode
public void writeFromUserCode(WriteMessage message)
- Specified by:
writeFromUserCodein classAbstractSession
-
schduleWriteMessage
protected boolean schduleWriteMessage(WriteMessage writeMessage)
-
flush
public void flush()
Description copied from interface:SessionFlush the write queue,this method may be no effect if OP_WRITE is running.
-
flush0
protected final void flush0()
-
doRealWrite
protected final long doRealWrite(java.nio.channels.SelectableChannel channel, IoBuffer buffer) throws java.io.IOException- Throws:
java.io.IOException
-
onEvent
public final void onEvent(EventType event, java.nio.channels.Selector selector)
�ɷ�IO�¼�- Specified by:
onEventin interfaceNioSession
-
-