public class NonBlockingClientHandler extends BasicClientHandler
| Modifier and Type | Field and Description |
|---|---|
protected ClientWriteHandler |
clientWriteHandler |
protected java.util.ArrayList |
readByteBuffer |
protected java.nio.channels.SelectionKey |
selectionKey |
protected int |
threadAccessCount |
protected boolean |
waitingForFinalWrite |
protected boolean |
willReturn |
protected java.util.ArrayList |
writeByteBuffer |
appLogger, authenticator, authorised, b_in, b_out, bufferedReader, charset, clientAuthenticationHandler, clientBinaryHandler, clientCommandHandler, clientConnectedTime, clientData, clientEventHandler, clientEvents, clientExtendedEventHandler, clientObjectHandler, closeOrLostNotified, communicationLogging, connection, counAuthTry, dataModeIN, dataModeOUT, in, lastCommunicationTime, lockObj, lost, maxAuthTry, maxAuthTryMsg, maxConnectionMsg, NEW_LINE, NEW_LINE_BYTES, o_in, o_out, out, quickServer, secure, socket, socketTimeout, sslEngine, threadEvent, timeoutMsg, totalReadBytes, totalWrittenBytes, unprocessedClientEvents, willClean| Constructor and Description |
|---|
NonBlockingClientHandler() |
NonBlockingClientHandler(int instanceCount) |
| Modifier and Type | Method and Description |
|---|---|
protected boolean |
checkReturnClientHandler() |
void |
clean() |
void |
closeConnection()
Closes client socket associated.
|
boolean |
closeIfSSLOutboundDone() |
java.nio.ByteBuffer |
encrypt(java.nio.ByteBuffer src) |
boolean |
getBlockingMode()
Returns the current blocking mode of the server.
|
java.io.BufferedReader |
getBufferedReader()
Returns the
BufferedReader associated with
the Client being handled. |
boolean |
getInitialHandshakeStatus() |
static int |
getMaxThreadAccessCount()
Returns the maximum count of thread allowed to run objects of this class at a time.
|
java.nio.channels.SelectionKey |
getSelectionKey()
Returns client SelectionKey associated, if any.
|
java.nio.channels.SocketChannel |
getSocketChannel()
Returns client socket channel associated, if any.
|
int |
getThreadAccessCount()
Returns number of thread currently in this object.
|
static boolean |
getWakeupSelectorAfterRegisterRead()
Returns wakeupSelectorAfterRegisterRead the flag that controls if wakeup is called on Selector
after RegisterForRead is called.
|
static boolean |
getWakeupSelectorAfterRegisterWrite()
Returns wakeupSelectorAfterRegisterWrite the flag that controls if wakeup is called on Selector
after RegisterForWrite is called.
|
void |
handleClient(TheClient theClient)
Associates the ClientHanlder with the client encapsulated by
theClient. |
protected byte[] |
readInputStream()
Read the byte input.
|
void |
registerForRead()
Register OP_READ with the SelectionKey associated with the channel.
|
void |
registerForWrite()
Register OP_WRITE with the SelectionKey associated with the channel.
|
void |
registerWrite() |
protected void |
returnClientHandler() |
protected void |
returnThread() |
void |
run() |
protected void |
setClientWriteHandler(ClientWriteHandler handler)
Sets the ClientWriteHandler class that interacts with
client sockets.
|
void |
setDataMode(DataMode dataMode,
DataType dataType)
Sets the
DataMode for the ClientHandler
Note: When mode is DataMode.OBJECT and type is DataType.IN
this call will block until the client ObjectOutputStream has
written and flushes the header. |
protected void |
setInputStream(java.io.InputStream in)
Sets the
InputStream associated with
the Client being handled. |
static void |
setMaxThreadAccessCount(int count)
Sets the maximum count of thread allowed to run objects of this class at a time.
|
void |
setSelectionKey(java.nio.channels.SelectionKey selectionKey)
Sets client SelectionKey associated, if any.
|
void |
setSocketChannel(java.nio.channels.SocketChannel socketChannel)
Sets client socket channel associated, if any.
|
static void |
setWakeupSelectorAfterRegisterRead(boolean flag)
Sets the flag to wakeup Selector After RegisterForRead is called.
|
static void |
setWakeupSelectorAfterRegisterWrite(boolean flag)
Sets the flag to wakeup Selector After RegisterForWrite is called.
|
void |
updateInputOutputStreams()
Updates the InputStream and OutputStream for the ClientHandler for the
set Socket.
|
void |
waitTillFullyWritten()
waitTillFullyWritten
|
addEvent, assertionSystemExit, checkDataModeSet, forceClose, getAppLogger, getBufferedInputStream, getBufferedOutputStream, getBufferedWriter, getCharset, getClientConnectedTime, getClientData, getClientIdentifiable, getCommunicationLogging, getConnection, getDataMode, getHostAddress, getInputStream, getInstanceCount, getLastCommunicationTime, getMaxConnectionMsg, getName, getObjectInputStream, getObjectOutputStream, getOutputStream, getServer, getSocket, getSSLEngine, getThreadEvent, getTimeout, getTotalReadBytes, getTotalWrittenBytes, getWillClean, handleTimeout, hasEvent, info, isClientEventNext, isClosed, isConected, isConnected, isOpen, isSecure, makeSecure, makeSecure, makeSecure, notifyCloseOrLost, prepareForRun, processAuthorisation, processMaxConnection, readBinary, readBytes, readInputStream, removeEvent, resetTotalReadBytes, resetTotalWrittenBytes, returnClientData, sendClientBinary, sendClientBinary, sendClientBytes, sendClientMsg, sendClientObject, sendSystemMsg, sendSystemMsg, sendSystemMsg, setAuthenticator, setCharset, setClientAuthenticationHandler, setClientBinaryHandler, setClientCommandHandler, setClientData, setClientEventHandler, setClientExtendedEventHandler, setClientObjectHandler, setCommunicationLogging, setMaxConnectionMsg, setOutputStream, setSecure, setServer, setSocket, setTimeout, toString, updateLastCommunicationTimeprotected ClientWriteHandler clientWriteHandler
protected java.util.ArrayList readByteBuffer
protected java.util.ArrayList writeByteBuffer
protected java.nio.channels.SelectionKey selectionKey
protected volatile int threadAccessCount
protected volatile boolean willReturn
protected volatile boolean waitingForFinalWrite
public NonBlockingClientHandler(int instanceCount)
public NonBlockingClientHandler()
public static void setWakeupSelectorAfterRegisterWrite(boolean flag)
public static boolean getWakeupSelectorAfterRegisterWrite()
public static void setWakeupSelectorAfterRegisterRead(boolean flag)
public static boolean getWakeupSelectorAfterRegisterRead()
public static void setMaxThreadAccessCount(int count)
public static int getMaxThreadAccessCount()
public void clean()
clean in interface ClientHandlerclean in class BasicClientHandlerpublic void handleClient(TheClient theClient) throws java.lang.Exception
BasicClientHandlertheClient.handleClient in interface ClientHandlerhandleClient in class BasicClientHandlertheClient - object that encapsulates client socket
and its configuration details.java.lang.Exceptionprotected void setInputStream(java.io.InputStream in)
throws java.io.IOException
BasicClientHandlerInputStream associated with
the Client being handled.setInputStream in class BasicClientHandlerjava.io.IOExceptionBasicClientHandler.getInputStream()public java.io.BufferedReader getBufferedReader()
BasicClientHandlerBufferedReader associated with
the Client being handled. Note that this is only available under blocking mode.getBufferedReader in interface ClientHandlergetBufferedReader in class BasicClientHandlerBasicClientHandler.getBufferedWriter()public void closeConnection()
BasicClientHandlercloseConnection in interface ClientHandlercloseConnection in class BasicClientHandlerpublic boolean closeIfSSLOutboundDone()
public void waitTillFullyWritten()
public void run()
run in interface java.lang.Runnablerun in interface ClientHandlerrun in class BasicClientHandlerprotected boolean checkReturnClientHandler()
protected void returnThread()
protected void returnClientHandler()
returnClientHandler in class BasicClientHandlerpublic void setDataMode(DataMode dataMode, DataType dataType) throws java.io.IOException
BasicClientHandlerDataMode for the ClientHandler
Note: When mode is DataMode.OBJECT and type is DataType.IN
this call will block until the client ObjectOutputStream has
written and flushes the header.setDataMode in interface ClientHandlersetDataMode in class BasicClientHandlerdataMode - mode of data exchange - String or Object.dataType - type of data for which mode has to be set.java.io.IOException - if mode could not be changed.protected byte[] readInputStream()
throws java.io.IOException
BasicClientHandlerreadInputStream in class BasicClientHandlerjava.io.IOExceptionpublic void updateInputOutputStreams()
throws java.io.IOException
BasicClientHandlerupdateInputOutputStreams in interface ClientHandlerupdateInputOutputStreams in class BasicClientHandlerjava.io.IOExceptionBasicClientHandler.setSocket(java.net.Socket)public boolean getBlockingMode()
BasicClientHandlergetBlockingMode in class BasicClientHandlerpublic void setSocketChannel(java.nio.channels.SocketChannel socketChannel)
BasicClientHandlersetSocketChannel in interface ClientHandlersetSocketChannel in class BasicClientHandlerpublic java.nio.channels.SocketChannel getSocketChannel()
BasicClientHandlergetSocketChannel in interface ClientHandlergetSocketChannel in class BasicClientHandlerpublic void setSelectionKey(java.nio.channels.SelectionKey selectionKey)
BasicClientHandlersetSelectionKey in interface ClientHandlersetSelectionKey in class BasicClientHandlerpublic java.nio.channels.SelectionKey getSelectionKey()
BasicClientHandlergetSelectionKey in interface ClientHandlergetSelectionKey in class BasicClientHandlerpublic void registerForRead()
throws java.io.IOException,
java.nio.channels.ClosedChannelException
BasicClientHandlerregisterForRead in interface ClientHandlerregisterForRead in class BasicClientHandlerjava.io.IOExceptionjava.nio.channels.ClosedChannelExceptionpublic void registerForWrite()
throws java.io.IOException,
java.nio.channels.ClosedChannelException
BasicClientHandlerregisterForWrite in interface ClientHandlerregisterForWrite in class BasicClientHandlerjava.io.IOExceptionjava.nio.channels.ClosedChannelExceptionpublic void registerWrite()
throws java.io.IOException
java.io.IOExceptionprotected void setClientWriteHandler(ClientWriteHandler handler)
BasicClientHandlersetClientWriteHandler in class BasicClientHandlerhandler - fully qualified name of the class that
implements ClientWriteHandlerpublic int getThreadAccessCount()
public boolean getInitialHandshakeStatus()
public java.nio.ByteBuffer encrypt(java.nio.ByteBuffer src)
throws java.io.IOException
java.io.IOExceptionCopyright © 2003-2014 QuickServer.org