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
Abstract nio session
-
Nested Class Summary
Nested classes/interfaces inherited from interface com.google.code.yanf4j.core.Session
Session.SessionStatus
-
Field Summary
FieldsFields 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 -
Method Summary
Modifier and TypeMethodDescriptionchannel()
return the channel for this connectionprotected void
protected final long
doRealWrite
(SelectableChannel channel, IoBuffer buffer) final void
enableRead
(Selector selector) Enable read eventfinal void
enableWrite
(Selector selector) Enable write eventvoid
flush()
Flush the write queue,this method may be no effect if OP_WRITE is running.protected final void
flush0()
private void
interestRead
(SelectionKey key) private void
final void
�ɷ�IO�¼�protected void
onRead
(SelectionKey key) protected void
onWrite
(SelectionKey key) protected abstract void
protected final void
protected boolean
schduleWriteMessage
(WriteMessage writeMessage) protected void
start0()
protected final void
protected void
void
writeFromUserCode
(WriteMessage message) protected abstract Object
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 Details
-
selectorManager
-
selectableChannel
-
-
Constructor Details
-
AbstractNioSession
-
-
Method Details
-
channel
Description copied from interface:NioSession
return the channel for this connection- Specified by:
channel
in interfaceNioSession
- Returns:
-
enableRead
Description copied from interface:NioSession
Enable read event- Specified by:
enableRead
in interfaceNioSession
- Parameters:
selector
-
-
interestRead
-
start0
protected void start0()- Specified by:
start0
in classAbstractSession
-
getLocalAddress
- Specified by:
getLocalAddress
in interfaceSession
-
writeToChannel
protected abstract Object writeToChannel(WriteMessage msg) throws ClosedChannelException, IOException - Throws:
ClosedChannelException
IOException
-
onWrite
-
enableWrite
Description copied from interface:NioSession
Enable write event- Specified by:
enableWrite
in interfaceNioSession
- Parameters:
selector
-
-
interestWrite
-
onRead
-
readFromBuffer
protected abstract void readFromBuffer() -
closeChannel
- Specified by:
closeChannel
in classAbstractSession
- Throws:
IOException
-
unregisterChannel
- Throws:
IOException
-
registerSession
protected final void registerSession() -
unregisterSession
protected void unregisterSession() -
writeFromUserCode
- Specified by:
writeFromUserCode
in classAbstractSession
-
schduleWriteMessage
-
flush
public void flush()Description copied from interface:Session
Flush the write queue,this method may be no effect if OP_WRITE is running. -
flush0
protected final void flush0() -
doRealWrite
- Throws:
IOException
-
onEvent
�ɷ�IO�¼�- Specified by:
onEvent
in interfaceNioSession
- Parameters:
event
-selector
-
-