Package one.nio.net
Class Session
- java.lang.Object
-
- one.nio.net.Session
-
- All Implemented Interfaces:
Closeable,AutoCloseable
- Direct Known Subclasses:
HttpSession,RpcSession
public class Session extends Object implements Closeable
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classSession.ArrayQueueItemstatic classSession.QueueItem
-
Field Summary
Fields Modifier and Type Field Description static intACTIVEprotected booleanclosingstatic intCLOSINGstatic intEVENT_MASKprotected inteventsprotected inteventsToListenstatic intIDLEprotected longlastAccessTimeprotected static org.slf4j.Loggerlogprotected Session.QueueItemqueueHeadstatic intREADABLEprotected Selectorselectorprotected intslotprotected Socketsocketstatic intSSLstatic intSTALEprotected booleanwasSelectedstatic intWRITEABLE
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intcheckStatus(long currentTime, long keepAlive)voidclose()voidgetQueueStats(long[] stats)StringgetRemoteHost()voidhandleException(Throwable e)booleanisSsl()longlastAccessTime()voidlisten(int newEventsToListen)voidprocess(byte[] buffer)protected voidprocessRead(byte[] buffer)protected voidprocessWrite()intread(byte[] data, int offset, int count)intreadRaw(long address, int count)voidscheduleClose()Socketsocket()voidwrite(byte[] data, int offset, int count)voidwrite(byte[] data, int offset, int count, int flags)voidwrite(Session.QueueItem item)
-
-
-
Field Detail
-
log
protected static final org.slf4j.Logger log
-
READABLE
public static final int READABLE
- See Also:
- Constant Field Values
-
WRITEABLE
public static final int WRITEABLE
- See Also:
- Constant Field Values
-
CLOSING
public static final int CLOSING
- See Also:
- Constant Field Values
-
EVENT_MASK
public static final int EVENT_MASK
- See Also:
- Constant Field Values
-
SSL
public static final int SSL
- See Also:
- Constant Field Values
-
ACTIVE
public static final int ACTIVE
- See Also:
- Constant Field Values
-
IDLE
public static final int IDLE
- See Also:
- Constant Field Values
-
STALE
public static final int STALE
- See Also:
- Constant Field Values
-
socket
protected Socket socket
-
selector
protected Selector selector
-
slot
protected int slot
-
events
protected int events
-
eventsToListen
protected int eventsToListen
-
wasSelected
protected boolean wasSelected
-
closing
protected boolean closing
-
queueHead
protected Session.QueueItem queueHead
-
lastAccessTime
protected volatile long lastAccessTime
-
-
Method Detail
-
getRemoteHost
public final String getRemoteHost()
-
socket
public final Socket socket()
-
lastAccessTime
public final long lastAccessTime()
-
isSsl
public boolean isSsl()
-
checkStatus
public int checkStatus(long currentTime, long keepAlive)
-
close
public void close()
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable
-
scheduleClose
public void scheduleClose()
-
getQueueStats
public void getQueueStats(long[] stats)
-
listen
public void listen(int newEventsToListen)
-
read
public int read(byte[] data, int offset, int count) throws IOException- Throws:
IOException
-
readRaw
public int readRaw(long address, int count) throws IOException- Throws:
IOException
-
write
public final void write(byte[] data, int offset, int count) throws IOException- Throws:
IOException
-
write
public final void write(byte[] data, int offset, int count, int flags) throws IOException- Throws:
IOException
-
write
public final void write(Session.QueueItem item) throws IOException
- Throws:
IOException
-
handleException
public void handleException(Throwable e)
-
-